From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 119810 invoked by alias); 8 Oct 2019 09:05:33 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 119788 invoked by uid 89); 8 Oct 2019 09:05:32 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=no version=3.3.1 spammy=quotes, HX-HELO:sk:mail-ed, H*r:sk:mail-ed, HX-Received:906 X-HELO: mail-ed1-f48.google.com Received: from mail-ed1-f48.google.com (HELO mail-ed1-f48.google.com) (209.85.208.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 08 Oct 2019 09:05:31 +0000 Received: by mail-ed1-f48.google.com with SMTP id l21so14946781edr.5 for ; Tue, 08 Oct 2019 02:05:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=oIKHH8Qb1l/8z1YaYu7vx6LSFPYuFmtP0f6yd+uwEiU=; b=iN4kOzfosUacH/Si5qhd/B5czsJB8fc2gZL3EkvCuPTcgw7Kip2LlM3LtCPP9RgEBg ASkaxDL4IvhkBdFOeMWbBLX4XimI+0T/WF9vHHUzLApKWxHxuZYm/W0vFjNimE2MZfmY bdvBM3tQW1XQxcIQNgRjkMRjfc2cRtyXHafp92SVud3o++UhvVMnOklKyc4fUl1VRTg+ bzY3RNsZwvoA8+NqDlBrfr2HLOfKyySFOtg6J2kWgcGFN3DXb9hMGV6VDQSCACaLmHGm igga6cGy6EL/hQ94E+7JCwMAOI+am0DAwt3Plmw5dXAHez9DTG+Nr2EbngeXFJ6RCOu7 rmMw== MIME-Version: 1.0 From: Mingye Wang Date: Tue, 08 Oct 2019 09:05:00 -0000 Message-ID: Subject: [bug] globify dospath reacts poorly with escaped double quotes To: cygwin@cygwin.com Content-Type: text/plain; charset="UTF-8" X-SW-Source: 2019-10/txt/msg00033.txt.bz2 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?) -- Regards, Mingye Wang -- Mingye Wang (Artoria2e5) -- 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