From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 120042 invoked by alias); 10 Oct 2019 13:13:22 -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 120026 invoked by uid 89); 10 Oct 2019 13:13:22 -0000 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 Received: from mail-eopbgr730105.outbound.protection.outlook.com (HELO NAM05-DM3-obe.outbound.protection.outlook.com) (40.107.73.105) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 10 Oct 2019 13:13:20 +0000 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= Received: from DM6PR04MB5738.namprd04.prod.outlook.com (20.179.51.81) by DM6PR04MB6412.namprd04.prod.outlook.com (10.141.162.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.19; Thu, 10 Oct 2019 13:13:18 +0000 Received: from DM6PR04MB5738.namprd04.prod.outlook.com ([fe80::6998:197f:bcff:7172]) by DM6PR04MB5738.namprd04.prod.outlook.com ([fe80::6998:197f:bcff:7172%4]) with mapi id 15.20.2347.016; Thu, 10 Oct 2019 13:13:18 +0000 From: Ken Brown To: "cygwin@cygwin.com" Subject: Re: [bug] globify dospath reacts poorly with escaped double quotes Date: Thu, 10 Oct 2019 13:13:00 -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@cornell.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: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: iMzLv2KXJifKOAM2D8j7g4esOEs9AXoBhiG3vyyN9EJegtb3H7YZF01sP3QPQ9Hi6TrVDCj89XhqTtTavw0XjA== X-IsSubscribed: yes X-SW-Source: 2019-10/txt/msg00056.txt.bz2 On 10/8/2019 5:05 AM, Mingye Wang wrote: > Hi, >=20 > This bug is inherited from early versions of Cygwin. It's so old that > MSYS2 has this problem too. >=20 > 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(). >=20 > This is problematic for programmers trying to write a routine to > reliably escape an argument for the Cygwin command-line. >=20 > A way to patch the problem is with a lookahead in globify(): >=20 > if (dos_spec && *s =3D=3D '\\') { > /**/p++ =3D '\\'; > /**/if (s[1] =3D=3D '"' && s[2]) { > /****/*p =3D *++s; > /****/continue; > /**/} > } > *p =3D *s; >=20 > [Apologies for the formatting; the gmail web editor hates leading spaces.] >=20 > (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=20 substance of this. But it would help those who do if you would send your p= atch=20 to the cygwin-patches mailing list using git format-patch and git send-emai= l.=20 And please use the formatting conventions of the surrounding code. For exa= mple, if (dos_spec && *s =3D=3D '\\') { [...] } 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