[bug] globify dospath reacts poorly with escaped double quotes
Ken Brown
kbrown@cornell.edu
Thu Oct 10 13:13:00 GMT 2019
On 10/8/2019 5:05 AM, Mingye Wang wrote:
> Hi,
>
> This bug is inherited from early versions of Cygwin. It's so old that
> MSYS2 has this problem too.
>
> There is no way of conveying a double quote in an argument once
> globify() decides it has seen a dospath. Neither the `\"` nor `""`
> work, because they are both unified to `\"` in quoted() and turned
> into a `\\` pattern in globify().
>
> This is problematic for programmers trying to write a routine to
> reliably escape an argument for the Cygwin command-line.
>
> A way to patch the problem is with a lookahead in globify():
>
> if (dos_spec && *s == '\\') {
> /**/p++ = '\\';
> /**/if (s[1] == '"' && s[2]) {
> /****/*p = *++s;
> /****/continue;
> /**/}
> }
> *p = *s;
>
> [Apologies for the formatting; the gmail web editor hates leading spaces.]
>
> (Note: The backslash thing has always been different from the MSCRT
> handling, which only transforms backslashes followed by a double
> quote. But this is fine as long as we are internally consistent.
> Well... is it documented anywhere?)
I don't know enough about Windows command-line quoting to comment on the
substance of this. But it would help those who do if you would send your patch
to the cygwin-patches mailing list using git format-patch and git send-email.
And please use the formatting conventions of the surrounding code. For example,
if (dos_spec && *s == '\\')
{
[...]
}
Thanks.
Ken
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
More information about the Cygwin
mailing list