Patchwork posix: shellquote do not require quoting for "+" (issue4818)

login
register
mail settings
Submitter timeless@mozdev.org
Date Sept. 11, 2015, 7:27 p.m.
Message ID <3cf8adae162715009b09.1441999673@waste.org>
Download mbox | patch
Permalink /patch/10486/
State Accepted
Headers show

Comments

timeless@mozdev.org - Sept. 11, 2015, 7:27 p.m.
# HG changeset patch
# User timeless@mozdev.org
# Date 1441379702 14400
#      Fri Sep 04 11:15:02 2015 -0400
# Node ID 3cf8adae162715009b09fc38145d5349160232be
# Parent  ea489d94e1dc1fc3dc1dcbef1c86c18c49605ed1
posix: shellquote do not require quoting for "+" (issue4818)
Pierre-Yves David - Sept. 14, 2015, 11:01 p.m.
On 09/11/2015 12:27 PM, timeless@mozdev.org wrote:
> # HG changeset patch
> # User timeless@mozdev.org
> # Date 1441379702 14400
> #      Fri Sep 04 11:15:02 2015 -0400
> # Node ID 3cf8adae162715009b09fc38145d5349160232be
> # Parent  ea489d94e1dc1fc3dc1dcbef1c86c18c49605ed1
> posix: shellquote do not require quoting for "+" (issue4818)

I would like to be sure this is safe. I've commented on the issue,
Matt Mackall - Sept. 16, 2015, 7:55 p.m.
On Fri, 2015-09-11 at 14:27 -0500, timeless@mozdev.org wrote:
> # HG changeset patch
> # User timeless@mozdev.org
> # Date 1441379702 14400
> #      Fri Sep 04 11:15:02 2015 -0400
> # Node ID 3cf8adae162715009b09fc38145d5349160232be
> # Parent  ea489d94e1dc1fc3dc1dcbef1c86c18c49605ed1
> posix: shellquote do not require quoting for "+" (issue4818)

I poked around at some Posix specs and convinced myself this was fine.
For instance section 2.2 here:

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html

Queued for default, thanks.

Patch

diff --git a/mercurial/posix.py b/mercurial/posix.py
--- a/mercurial/posix.py
+++ b/mercurial/posix.py
@@ -350,7 +350,7 @@ 
         return '"%s"' % s
     global _needsshellquote
     if _needsshellquote is None:
-        _needsshellquote = re.compile(r'[^a-zA-Z0-9._/-]').search
+        _needsshellquote = re.compile(r'[^a-zA-Z0-9._/+-]').search
     if s and not _needsshellquote(s):
         # "s" shouldn't have to be quoted
         return s