X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:references :in-reply-to:content-type:content-id:content-transfer-encoding :mime-version; q=dns; s=default; b=OUzZ85FjydnLSVYZ83boAoTK7BKqN IpUwsfwzV1iFYqEDXkc2Xn1K6BBDAQuAh7qORBrRj5Z6TuewLGelC5RooGo4+i0x B9V7J20gdguCMXPaO/pMj7A8ElWMMtsz9AYralXclMPPDk5ABaGksAsP0Wz9jGda +cWIKC7m3YHsE8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:references :in-reply-to:content-type:content-id:content-transfer-encoding :mime-version; s=default; bh=w88X5MpnbdzWMGjuXSK7KyW5JKI=; b=fQO lwQGJ/KPaYs2nPwfTTYuMwvbrXSVRHsXSuKLTyMg7edWfZ20Xv0l5IEWyn8ResA9 t6xnGBJkKLaXLkkevFsciNuiaVDhMml/RzJfVSN75gggtmQE3WCQJ6DLk/42nu2D qcEz0T3gVYWQIHo/CsN1eTkQb0g7eorv6rO5u86Q= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-3.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 spammy=****, poorly, dospath, Mingye X-HELO: NAM05-DM3-obe.outbound.protection.outlook.com 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== 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-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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cornell.edu; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7QSMaBH6A6nXq48M3Vh69ddVPYwNk7kzny/98jobzVQ=; b=Q3BF3p62e49oLZl8YiPYhnV1I0GV4z1UvrbUSboxNTtxCcvizhdsBfDGi24VjqicVcXl/RZ0+3A6OhlzgTwGI+WWioikUpJagNfdg4ewRRA6+8+nxwyN27fIARLc3OKh6JKm/ZYQXRE4HsRHbE6P0E3EP1ZFW2ReO6WH1U5KrrE= From: Ken Brown To: "cygwin AT cygwin DOT com" Subject: Re: [bug] globify dospath reacts poorly with escaped double quotes Date: Thu, 10 Oct 2019 13:13:18 +0000 Message-ID: <4fea0000-424f-377f-7152-2e572b6f8d05@cornell.edu> References: In-Reply-To: user-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 authentication-results: spf=none (sender IP is ) smtp.mailfrom=kbrown AT cornell DOT edu; x-ms-oob-tlc-oobclassifiers: OLM:2089; received-spf: None (protection.outlook.com: cornell.edu does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="Windows-1252" Content-ID: MIME-Version: 1.0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: iMzLv2KXJifKOAM2D8j7g4esOEs9AXoBhiG3vyyN9EJegtb3H7YZF01sP3QPQ9Hi6TrVDCj89XhqTtTavw0XjA== X-IsSubscribed: yes Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id x9ADDwIe008635 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