This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: [bug] globify dospath reacts poorly with escaped double quotes
- From: Ken Brown <kbrown at cornell dot edu>
- To: "cygwin at cygwin dot com" <cygwin at cygwin dot com>
- Date: Thu, 10 Oct 2019 13:13:18 +0000
- Subject: Re: [bug] globify dospath reacts poorly with escaped double quotes
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=cornell.edu; dmarc=pass action=none header.from=cornell.edu; dkim=pass header.d=cornell.edu; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7QSMaBH6A6nXq48M3Vh69ddVPYwNk7kzny/98jobzVQ=; b=Jc91m+xiXFKnxnc2cc3oL/b0btBPs7+M1BQFoGPYpUn4PHwJL1FLtB7IV4t+oti/KK7Vyt1jBwQ7ibGog6fxEKSfQiNH3qN6hQWsl3shfSr0PTd1OzGCE5b+IjlSvUF8cN2kB4SikfrdpFxtaZ4W6Mey2VKGO/JUFJjK2KA816a1WoLhDnGwOdZna4NR+0hcKagz30a01TFG4L91Pq1ASz825gTAYxQ5/Os+xHYS5E+waQX36E4IDjLs2fwui7PBzYZNEelNZdwioJ2rEfzVqK2L0e1Va5P9CBTQhCPZiOJtwGLJov8ELO2NiULVbLlIcKf+0kYLC1qTwW7FhPOegw==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RTmJ0L5iPmRRmbP0AiaxFUZfToAjuCN1PVh4bLks6uW4behIEsnU3HViOSDndarqKl25NuyQyJoUhPyDMprV4kiCnpXwZgYGIcHYGib+K7p9vbbY1zfcC4LJwjPpH+JcMIM8W3OkDYNAQga3ivp6TTNDNtA/sL3ej9VMGrdw90hPeYtj+mYf05WN8k1MNThO6nanchiEztI0iAWVkgYxtmEcxsUBuPUqVeqdwu10nIN9PFSEofL1AAdjR/j1gGrPrAqRyTVPTPtWq/Ylxqf8pZEidUCFN5+M6IN5HF11LK29d53GyU+0o0awdgBCnrdG+Yz5kF8F0GCK4IN/zj4dXg==
- References: <CAD66C+b4uBtV=DUZ1n7Nk+KEoac0G9rkGYLVE7eEeKEuCKZmVA@mail.gmail.com>
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