Patchwork patchbomb: use procutil.shellquote() instead of shlex to escape email address

login
register
mail settings
Submitter Yuya Nishihara
Date Oct. 1, 2019, 11:21 p.m.
Message ID <7caa35ed514b937c9c4d.1569972060@mimosa>
Download mbox | patch
Permalink /patch/41923/
State Accepted
Headers show

Comments

Yuya Nishihara - Oct. 1, 2019, 11:21 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1569969322 -32400
#      Wed Oct 02 07:35:22 2019 +0900
# Node ID 7caa35ed514b937c9c4dd0b76cdee562f6746d73
# Parent  03e769278ef31f648ba5c49be719da5b73587607
patchbomb: use procutil.shellquote() instead of shlex to escape email address

This basically backs out 2cc453284d5c, and inserts procutil.shellquote()
instead. I don't care about Windows compatibility here, but shlex.quote()
can't handle byte strings on Python 3.
Augie Fackler - Oct. 8, 2019, 5:03 p.m.
> On Oct 1, 2019, at 19:21, Yuya Nishihara <yuya@tcha.org> wrote:
> 
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1569969322 -32400
> #      Wed Oct 02 07:35:22 2019 +0900
> # Node ID 7caa35ed514b937c9c4dd0b76cdee562f6746d73
> # Parent  03e769278ef31f648ba5c49be719da5b73587607
> patchbomb: use procutil.shellquote() instead of shlex to escape email address

queued, thanks

Patch

diff --git a/mercurial/mail.py b/mercurial/mail.py
--- a/mercurial/mail.py
+++ b/mercurial/mail.py
@@ -152,8 +152,8 @@  def _smtp(ui):
 def _sendmail(ui, sender, recipients, msg):
     '''send mail using sendmail.'''
     program = ui.config('email', 'method')
-    stremail = lambda x: (
-        procutil.quote(stringutil.email(encoding.strtolocal(x))))
+    def stremail(x):
+        return procutil.shellquote(stringutil.email(encoding.strtolocal(x)))
     cmdline = '%s -f %s %s' % (program, stremail(sender),
                                ' '.join(map(stremail, recipients)))
     ui.note(_('sending mail: %s\n') % cmdline)
diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py
--- a/mercurial/pycompat.py
+++ b/mercurial/pycompat.py
@@ -328,11 +328,8 @@  if ispy3:
         ret = shlex.split(s.decode('latin-1'), comments, posix)
         return [a.encode('latin-1') for a in ret]
 
-    shlexquote = shlex.quote
-
 else:
     import cStringIO
-    import pipes
 
     xrange = xrange
     unicode = unicode
@@ -396,7 +393,6 @@  else:
     sysplatform = sys.platform
     sysexecutable = sys.executable
     shlexsplit = shlex.split
-    shlexquote = pipes.quote
     bytesio = cStringIO.StringIO
     stringio = bytesio
     maplist = map
diff --git a/mercurial/utils/procutil.py b/mercurial/utils/procutil.py
--- a/mercurial/utils/procutil.py
+++ b/mercurial/utils/procutil.py
@@ -70,7 +70,6 @@  shellsplit = platform.shellsplit
 spawndetached = platform.spawndetached
 sshargs = platform.sshargs
 testpid = platform.testpid
-quote = pycompat.shlexquote
 
 try:
     setprocname = osutil.setprocname