public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Ken Brown <kbrown@cornell.edu>
To: "cygwin@cygwin.com" <cygwin@cygwin.com>
Subject: Re: [bug] globify dospath reacts poorly with escaped double quotes
Date: Thu, 10 Oct 2019 13:13:00 -0000	[thread overview]
Message-ID: <4fea0000-424f-377f-7152-2e572b6f8d05@cornell.edu> (raw)
In-Reply-To: <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

  parent reply	other threads:[~2019-10-10 13:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-08  9:05 Mingye Wang
2019-10-08 20:09 ` Brian Inglis
2019-10-10 16:37   ` Brian Inglis
2019-10-10 13:13 ` Ken Brown [this message]
2019-10-10  8:30 Mingye Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4fea0000-424f-377f-7152-2e572b6f8d05@cornell.edu \
    --to=kbrown@cornell.edu \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).