colis-language icon indicating copy to clipboard operation
colis-language copied to clipboard

Escaping characters kept during the whole toolchain

Open Niols opened this issue 5 years ago • 8 comments

Take package libkf5xmlrpcclient5. Here is its preinst:

dpkg-maintscript-helper rm_conffile /etc/xdg/kxmlrpcclient.categories 5.61.0-1\~\~ -- "$@"
dpkg-maintscript-helper rm_conffile /etc/xdg/kxmlrpcclient.renamecategories -- "$@"

Now run colis-language on this script. You get the following in the logs:

 [ERR] wrong version 5.61.0-1\~\~

This is the symbolic version of the utility dpkg-maintscript-helper complaining that 5.61.0-1\~\~ is not a valid version number. And this is correct, as the version number that would actually reach dpkg-maintscript-helper in the original script is 5.61.0-1~~ which is a valid version number.

Now this comes from the fact that Morbig, in its parser of words, keeps the backslashes. It has already been mentionned in colis-anr/morbig#110, but this issue has not gotten any answer yet, so I don't know whether it is a bug that should be fixed or a feature. In the first case, the bug should be fixed in Morbig. In the second case, the conversion to Colis needs to take that into account.

@yurug Which is it?

Niols avatar Feb 21 '20 12:02 Niols

That being said, in package ipset, whose preinst is:

dpkg-maintscript-helper rm_conffile /etc/bash_completion.d/ipset 6.25.1-1~ -- "$@"

we get:

[ERR] wrong version 6.25.1-1~

which should be a valid version, in which case our version parser in our symbolic utility dpkg-maintscript-helper would be broken too? @treinen What do you think?

Niols avatar Feb 21 '20 12:02 Niols

Yes that is a valid version, since about 10 years (when we added the "~" character to the syntax of version strings).

Just to be sure that this is not due to an antediluvian version of dpkg: can you please try

dpkg --validate-version 6.25.1-1~ && echo OK

on the machine where you have observed that error ?

Ralf Treinen Institut de Recherche en Informatique Fondamentale Pôle Preuves, Programmes et Systèmes Université de Paris http://www.irif.fr/~treinen/

treinen avatar Feb 21 '20 13:02 treinen

How stupid can I be. There was indeed no dpkg on the machine. Forget that second point… What surprises me a bit more is that 5.61.0-1\~\~ seems to be accepted? I'll investigate a bit more in an environment with dpkg…

Niols avatar Feb 21 '20 13:02 Niols

a machine without dpkg, how is that possible?

maybe availability of dpkg could be checked at startup of the tool.

Ralf Treinen Institut de Recherche en Informatique Fondamentale Pôle Preuves, Programmes et Systèmes Université de Paris http://www.irif.fr/~treinen/

treinen avatar Feb 21 '20 13:02 treinen

The "" character is not allowed in debian version strings. Aren't these "" simply interpreted by the shell ?

Ralf Treinen Institut de Recherche en Informatique Fondamentale Pôle Preuves, Programmes et Systèmes Université de Paris http://www.irif.fr/~treinen/

treinen avatar Feb 21 '20 13:02 treinen

a machine without dpkg, how is that possible?

My arch linux laptop.

maybe availability of dpkg could be checked at startup of the tool.

Or at least dynamically when handling the return value of the call to dpkg (if the return code is 127 for instance).

Niols avatar Feb 21 '20 15:02 Niols

The "" character is not allowed in debian version strings. Aren't these "" simply interpreted by the shell ?

On the given example, they are here to protect the special character ~ (although it is not so special at that place, so I don't know), and they disappear during the expansion phase of the Shell. But we don't have an expansion phase per se, so we can either consider that it should be removed in the parsing of CST words (and in Morbig) or in the expansion (emulated by the conversion, or in the evaluation semantics of Colis).

Niols avatar Feb 21 '20 16:02 Niols

On Fri, Feb 21, 2020 at 08:01:01AM -0800, Nicolas Jeannerod wrote:

The "" character is not allowed in debian version strings. Aren't these "" simply interpreted by the shell ?

On the given example, they are here to protect the special character ~ (although it is not so special at that place, so I don't know), and they disappear during the expansion phase of the Shell. But we don't have an expansion phase per se, so we can either consider that it should be removed in the parsing of CST words (and in Morbig) or in the expansion (emulated by the conversion, or in the evaluation semantics of Colis).

The implementation uses Sys.command to execute dpkg with some arguments, and Sys.command calls the shell.

-Ralf.

Ralf Treinen Institut de Recherche en Informatique Fondamentale Pôle Preuves, Programmes et Systèmes Université de Paris http://www.irif.fr/~treinen/

treinen avatar Feb 21 '20 16:02 treinen