##// END OF EJS Templates
patchbomb: protect email addresses from shell...
Floris Bruynooghe -
r43289:2cc45328 default
parent child Browse files
Show More
@@ -152,7 +152,8 b' def _smtp(ui):'
152 def _sendmail(ui, sender, recipients, msg):
152 def _sendmail(ui, sender, recipients, msg):
153 '''send mail using sendmail.'''
153 '''send mail using sendmail.'''
154 program = ui.config('email', 'method')
154 program = ui.config('email', 'method')
155 stremail = lambda x: stringutil.email(encoding.strtolocal(x))
155 stremail = lambda x: (
156 procutil.quote(stringutil.email(encoding.strtolocal(x))))
156 cmdline = '%s -f %s %s' % (program, stremail(sender),
157 cmdline = '%s -f %s %s' % (program, stremail(sender),
157 ' '.join(map(stremail, recipients)))
158 ' '.join(map(stremail, recipients)))
158 ui.note(_('sending mail: %s\n') % cmdline)
159 ui.note(_('sending mail: %s\n') % cmdline)
@@ -328,8 +328,11 b' if ispy3:'
328 ret = shlex.split(s.decode('latin-1'), comments, posix)
328 ret = shlex.split(s.decode('latin-1'), comments, posix)
329 return [a.encode('latin-1') for a in ret]
329 return [a.encode('latin-1') for a in ret]
330
330
331 shlexquote = shlex.quote
332
331 else:
333 else:
332 import cStringIO
334 import cStringIO
335 import pipes
333
336
334 xrange = xrange
337 xrange = xrange
335 unicode = unicode
338 unicode = unicode
@@ -393,6 +396,7 b' else:'
393 sysplatform = sys.platform
396 sysplatform = sys.platform
394 sysexecutable = sys.executable
397 sysexecutable = sys.executable
395 shlexsplit = shlex.split
398 shlexsplit = shlex.split
399 shlexquote = pipes.quote
396 bytesio = cStringIO.StringIO
400 bytesio = cStringIO.StringIO
397 stringio = bytesio
401 stringio = bytesio
398 maplist = map
402 maplist = map
@@ -70,6 +70,7 b' shellsplit = platform.shellsplit'
70 spawndetached = platform.spawndetached
70 spawndetached = platform.spawndetached
71 sshargs = platform.sshargs
71 sshargs = platform.sshargs
72 testpid = platform.testpid
72 testpid = platform.testpid
73 quote = pycompat.shlexquote
73
74
74 try:
75 try:
75 setprocname = osutil.setprocname
76 setprocname = osutil.setprocname
@@ -3035,6 +3035,47 b' single rev'
3035 sending [PATCH] test ...
3035 sending [PATCH] test ...
3036 sending mail: $TESTTMP/t2/pretendmail.sh -f test foo
3036 sending mail: $TESTTMP/t2/pretendmail.sh -f test foo
3037
3037
3038 Shell characters in addresses
3039
3040 $ hg email --date '1980-1-1 0:1' -v -t '~foo/bar@example.com' -f 'me*@example.com' -r '10'
3041 this patch series consists of 1 patches.
3042
3043 warning: invalid patchbomb.intro value "mpmwearaclownnose"
3044 (should be one of always, never, auto)
3045 -f me*@example.com ~foo/bar@example.com
3046 MIME-Version: 1.0
3047 Content-Type: text/plain; charset="us-ascii"
3048 Content-Transfer-Encoding: 7bit
3049 Subject: [PATCH] dd
3050 X-Mercurial-Node: 3b6f1ec9dde933a40a115a7990f8b320477231af
3051 X-Mercurial-Series-Index: 1
3052 X-Mercurial-Series-Total: 1
3053 Message-Id: <3b6f1ec9dde933a40a11.315532860@test-hostname>
3054 X-Mercurial-Series-Id: <3b6f1ec9dde933a40a11.315532860@test-hostname>
3055 User-Agent: Mercurial-patchbomb/* (glob)
3056 Date: Tue, 01 Jan 1980 00:01:00 +0000
3057 From: me*@example.com
3058 To: ~foo/bar@example.com
3059
3060 # HG changeset patch
3061 # User test
3062 # Date 5 0
3063 # Thu Jan 01 00:00:05 1970 +0000
3064 # Branch test
3065 # Node ID 3b6f1ec9dde933a40a115a7990f8b320477231af
3066 # Parent 2f9fa9b998c5fe3ac2bd9a2b14bfcbeecbc7c268
3067 dd
3068
3069 diff -r 2f9fa9b998c5 -r 3b6f1ec9dde9 d
3070 --- a/d Thu Jan 01 00:00:04 1970 +0000
3071 +++ b/d Thu Jan 01 00:00:05 1970 +0000
3072 @@ -1,1 +1,2 @@
3073 d
3074 +d
3075
3076 sending [PATCH] dd ...
3077 sending mail: $TESTTMP/t2/pretendmail.sh -f 'me*@example.com' '~foo/bar@example.com'
3078
3038 Test pull url header
3079 Test pull url header
3039 =================================
3080 =================================
3040
3081
General Comments 0
You need to be logged in to leave comments. Login now