Patchwork [V2] mail: encode long unicode lines in emails properly (issue5687)

login
register
mail settings
Submitter Ippolitov Igor
Date Sept. 26, 2017, 1:56 p.m.
Message ID <7517d15f37a7a2480e25.1506434213@iippolitov-laptop>
Download mbox | patch
Permalink /patch/24162/
State Accepted
Headers show

Comments

Ippolitov Igor - Sept. 26, 2017, 1:56 p.m.
# HG changeset patch
# User Igor Ippolitov <iippolitov@gmail.com>
# Date 1506431697 -10800
#      Tue Sep 26 16:14:57 2017 +0300
# Node ID 7517d15f37a7a2480e250ba8e95514534f9a48bf
# Parent  05131c963767faaac6a66b2c658659bfbb4db29b
mail: encode long unicode lines in emails properly (issue5687)

3e544c074459 introduced a bug: emails Content-Transfer-Encoding
is silently replaced with 'quoted-printable' while any other
encoding could be used by underlying code. The problem is revealed
when a long unicode line is encoded.

The patch implements proper check which works for any text and
encoding.
Yuya Nishihara - Sept. 26, 2017, 2:12 p.m.
On Tue, 26 Sep 2017 16:56:53 +0300, Ippolitov Igor wrote:
> # HG changeset patch
> # User Igor Ippolitov <iippolitov@gmail.com>
> # Date 1506431697 -10800
> #      Tue Sep 26 16:14:57 2017 +0300
> # Node ID 7517d15f37a7a2480e250ba8e95514534f9a48bf
> # Parent  05131c963767faaac6a66b2c658659bfbb4db29b
> mail: encode long unicode lines in emails properly (issue5687)

Queued, thanks.

> diff -r 05131c963767 -r 7517d15f37a7 mercurial/mail.py
> --- a/mercurial/mail.py	Wed Sep 20 09:35:45 2017 -0700
> +++ b/mercurial/mail.py	Tue Sep 26 16:14:57 2017 +0300
> @@ -216,17 +216,17 @@
>      '''Return MIME message.
>      Quoted-printable transfer encoding will be used if necessary.
>      '''
> -    enc = None
> +    cs = email.charset.Charset(charset)
> +    msg = email.Message.Message()

s/email.Message.Message/email.message.Message/ for future Py3 compatibility,
and adjusted the import line accordingly.

Patch

diff -r 05131c963767 -r 7517d15f37a7 mercurial/mail.py
--- a/mercurial/mail.py	Wed Sep 20 09:35:45 2017 -0700
+++ b/mercurial/mail.py	Tue Sep 26 16:14:57 2017 +0300
@@ -216,17 +216,17 @@ 
     '''Return MIME message.
     Quoted-printable transfer encoding will be used if necessary.
     '''
-    enc = None
+    cs = email.charset.Charset(charset)
+    msg = email.Message.Message()
+    msg.set_type('text/'+subtype)
+
     for line in body.splitlines():
         if len(line) > 950:
-            body = quopri.encodestring(body)
-            enc = "quoted-printable"
+            cs.body_encoding = email.charset.QP
             break
 
-    msg = email.MIMEText.MIMEText(body, subtype, charset)
-    if enc:
-        del msg['Content-Transfer-Encoding']
-        msg['Content-Transfer-Encoding'] = enc
+    msg.set_payload(body, cs)
+
     return msg
 
 def _charsets(ui):
diff -r 05131c963767 -r 7517d15f37a7 tests/test-keyword.t
--- a/tests/test-keyword.t	Wed Sep 20 09:35:45 2017 -0700
+++ b/tests/test-keyword.t	Tue Sep 26 16:14:57 2017 +0300
@@ -260,8 +260,8 @@ 
   adding manifests
   adding file changes
   added 2 changesets with 3 changes to 3 files
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Date: * (glob)
   Subject: changeset in...
@@ -283,8 +283,8 @@ 
   @@ -0,0 +1,1 @@
   +a
   \ No newline at end of file
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Date:* (glob)
   Subject: changeset in...
diff -r 05131c963767 -r 7517d15f37a7 tests/test-notify-changegroup.t
--- a/tests/test-notify-changegroup.t	Wed Sep 20 09:35:45 2017 -0700
+++ b/tests/test-notify-changegroup.t	Tue Sep 26 16:14:57 2017 +0300
@@ -46,8 +46,8 @@ 
   adding manifests
   adding file changes
   added 2 changesets with 2 changes to 1 files
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Date: * (glob)
   Subject: * (glob)
@@ -97,8 +97,8 @@ 
   adding manifests
   adding file changes
   added 2 changesets with 2 changes to 1 files
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Date: * (glob)
   Subject: * (glob)
@@ -174,8 +174,8 @@ 
   adding manifests
   adding file changes
   added 4 changesets with 4 changes to 1 files
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Date: * (glob)
   Subject: * (glob)
diff -r 05131c963767 -r 7517d15f37a7 tests/test-notify.t
--- a/tests/test-notify.t	Wed Sep 20 09:35:45 2017 -0700
+++ b/tests/test-notify.t	Tue Sep 26 16:14:57 2017 +0300
@@ -188,8 +188,8 @@ 
   adding manifests
   adding file changes
   added 1 changesets with 1 changes to 1 files
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Date: * (glob)
   Subject: changeset in $TESTTMP/b: b
@@ -241,8 +241,8 @@ 
   adding manifests
   adding file changes
   added 1 changesets with 1 changes to 1 files
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   X-Test: foo
   Date: * (glob)
@@ -283,8 +283,8 @@ 
   adding manifests
   adding file changes
   added 1 changesets with 1 changes to 1 files
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   X-Test: foo
   Date: * (glob)
@@ -328,8 +328,8 @@ 
   adding manifests
   adding file changes
   added 2 changesets with 0 changes to 0 files
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   X-Test: foo
   Date: * (glob)
@@ -351,8 +351,8 @@ 
   +++ b/a	Thu Jan 01 00:00:02 1970 +0000
   @@ -1,1 +1,2 @@ a
   +a
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   X-Test: foo
   Date: * (glob)
@@ -383,8 +383,8 @@ 
   adding manifests
   adding file changes
   added 1 changesets with 1 changes to 1 files
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 8bit
   X-Test: foo
   Date: * (glob)
@@ -416,7 +416,7 @@ 
   > test = False
   > mbox = mbox
   > EOF
-  $ $PYTHON -c 'file("a/a", "ab").write("no" * 500 + "\n")'
+  $ $PYTHON -c 'file("a/a", "ab").write("no" * 500 + "\xd1\x84" + "\n")'
   $ hg --cwd a commit -A -m "long line"
   $ hg --traceback --cwd b pull ../a
   pulling from ../a
@@ -429,25 +429,25 @@ 
   (run 'hg update' to get a working copy)
   $ $PYTHON $TESTTMP/filter.py < b/mbox
   From test@test.com ... ... .. ..:..:.. .... (re)
-  Content-Type: text/plain; charset="us-ascii"
   MIME-Version: 1.0
+  Content-Type: text/plain; charset="*" (glob)
   Content-Transfer-Encoding: quoted-printable
   X-Test: foo
   Date: * (glob)
   Subject: long line
   From: test@test.com
-  X-Hg-Notification: changeset e0be44cf638b
-  Message-Id: <hg.e0be44cf638b.*.*@*> (glob)
+  X-Hg-Notification: changeset a323cae54f6e
+  Message-Id: <hg.a323cae54f6e.*.*@*> (glob)
   To: baz@test.com, foo@bar
   
-  changeset e0be44cf638b in b
+  changeset a323cae54f6e in b
   description: long line
   diffstat:
    a |  1 + 1 files changed, 1 insertions(+), 0 deletions(-)
   
   diffs (8 lines):
   
-  diff -r 7ea05ad269dc -r e0be44cf638b a
+  diff -r 7ea05ad269dc -r a323cae54f6e a
   --- a/a	Thu Jan 01 00:00:00 1970 +0000
   +++ b/a	Thu Jan 01 00:00:00 1970 +0000
   @@ -1,3 +1,4 @@ a a a
@@ -464,7 +464,7 @@ 
   ononononononononononononononononononononononononononononononononononononono=
   nononononononononononononononononononononononononononononononononononononon=
   ononononononononononononononononononononononononononononononononononononono=
-  nonononononononononononono
+  nonononononononononononono=D1=84
   
  revset selection: send to address that matches branch and repo
 
@@ -494,18 +494,18 @@ 
   adding manifests
   adding file changes
   added 1 changesets with 1 changes to 1 files
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   X-Test: foo
   Date: * (glob)
   Subject: test
   From: test@test.com
-  X-Hg-Notification: changeset fbbcbc516f2f
-  Message-Id: <hg.fbbcbc516f2f.*.*@*> (glob)
+  X-Hg-Notification: changeset b7cf10b2bdec
+  Message-Id: <hg.b7cf10b2bdec.*.*@*> (glob)
   To: baz@test.com, foo@bar, notify@example.com
   
-  changeset fbbcbc516f2f in b
+  changeset b7cf10b2bdec in b
   description: test
   (run 'hg update' to get a working copy)
 
@@ -523,18 +523,18 @@ 
   adding manifests
   adding file changes
   added 1 changesets with 0 changes to 0 files (+1 heads)
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   X-Test: foo
   Date: * (glob)
   Subject: test
   From: test@test.com
-  X-Hg-Notification: changeset 38b42fa092de
-  Message-Id: <hg.38b42fa092de.*.*@*> (glob)
+  X-Hg-Notification: changeset 5a07df312a79
+  Message-Id: <hg.5a07df312a79.*.*@*> (glob)
   To: baz@test.com, foo@bar
   
-  changeset 38b42fa092de in b
+  changeset 5a07df312a79 in b
   description: test
   (run 'hg heads' to see heads)
 
@@ -545,18 +545,18 @@ 
   $ echo a >> a/a
   $ hg --cwd a commit -m 'default template'
   $ hg --cwd b pull ../a -q | $PYTHON $TESTTMP/filter.py
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Date: * (glob)
   Subject: changeset in b: default template
   From: test@test.com
-  X-Hg-Notification: changeset 3548c9e294b6
-  Message-Id: <hg.3548c9e294b6.*.*@*> (glob)
+  X-Hg-Notification: changeset f5e8ec95bf59
+  Message-Id: <hg.f5e8ec95bf59.*.*@*> (glob)
   To: baz@test.com, foo@bar
   
-  changeset 3548c9e294b6 in $TESTTMP/b (glob)
-  details: http://test/b?cmd=changeset;node=3548c9e294b6
+  changeset f5e8ec95bf59 in $TESTTMP/b (glob)
+  details: http://test/b?cmd=changeset;node=f5e8ec95bf59
   description: default template
 
 with style:
@@ -574,17 +574,17 @@ 
   $ echo a >> a/a
   $ hg --cwd a commit -m 'with style'
   $ hg --cwd b pull ../a -q | $PYTHON $TESTTMP/filter.py
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Date: * (glob)
   Subject: with style
   From: test@test.com
-  X-Hg-Notification: changeset e917dbd961d3
-  Message-Id: <hg.e917dbd961d3.*.*@*> (glob)
+  X-Hg-Notification: changeset 9e2c3a8e9c43
+  Message-Id: <hg.9e2c3a8e9c43.*.*@*> (glob)
   To: baz@test.com, foo@bar
   
-  changeset e917dbd961d3
+  changeset 9e2c3a8e9c43
 
 with template (overrides style):
 
@@ -597,14 +597,14 @@ 
   $ echo a >> a/a
   $ hg --cwd a commit -m 'with template'
   $ hg --cwd b pull ../a -q | $PYTHON $TESTTMP/filter.py
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Date: * (glob)
-  Subject: a09743fd3edd: with template
+  Subject: e2cbf5bf18a7: with template
   From: test@test.com
-  X-Hg-Notification: changeset a09743fd3edd
-  Message-Id: <hg.a09743fd3edd.*.*@*> (glob)
+  X-Hg-Notification: changeset e2cbf5bf18a7
+  Message-Id: <hg.e2cbf5bf18a7.*.*@*> (glob)
   To: baz@test.com, foo@bar
   
   with template
diff -r 05131c963767 -r 7517d15f37a7 tests/test-patchbomb-bookmark.t
--- a/tests/test-patchbomb-bookmark.t	Wed Sep 20 09:35:45 2017 -0700
+++ b/tests/test-patchbomb-bookmark.t	Tue Sep 26 16:14:57 2017 +0300
@@ -31,8 +31,8 @@ 
   Cc: 
   
   displaying [PATCH 0 of 2] bookmark ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 0 of 2] bookmark
   Message-Id: <patchbomb.347155260@*> (glob)
@@ -43,8 +43,8 @@ 
   
   
   displaying [PATCH 1 of 2] first ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 1 of 2] first
   X-Mercurial-Node: accde9b8b6dce861c185d0825c1affc09a79cb26
@@ -74,8 +74,8 @@ 
   +first
   
   displaying [PATCH 2 of 2] second ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 2 of 2] second
   X-Mercurial-Node: 417defd1559c396ba06a44dce8dc1c2d2d653f3f
@@ -138,8 +138,8 @@ 
   Cc: 
   
   displaying [PATCH] bookmark ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH] bookmark
   X-Mercurial-Node: 8dab2639fd35f1e337ad866c372a5c44f1064e3c
diff -r 05131c963767 -r 7517d15f37a7 tests/test-patchbomb.t
--- a/tests/test-patchbomb.t	Wed Sep 20 09:35:45 2017 -0700
+++ b/tests/test-patchbomb.t	Tue Sep 26 16:14:57 2017 +0300
@@ -40,8 +40,8 @@ 
   
   
   displaying [PATCH] a ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH] a
   X-Mercurial-Node: 8580ff50825a50c8f716709acdf8de0deddcd6ab
@@ -115,8 +115,8 @@ 
   
   
   displaying [PATCH] a ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH] a
   X-Mercurial-Node: 8580ff50825a50c8f716709acdf8de0deddcd6ab
@@ -153,8 +153,8 @@ 
   
   
   displaying [PATCH] a ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH] a
   X-Mercurial-Node: 8580ff50825a50c8f716709acdf8de0deddcd6ab
@@ -195,8 +195,8 @@ 
   
   
   displaying [PATCH 0 of 2] test ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 0 of 2] test
   Message-Id: <patchbomb.120@*> (glob)
@@ -208,8 +208,8 @@ 
   
   
   displaying [PATCH 1 of 2] a ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 1 of 2] a
   X-Mercurial-Node: 8580ff50825a50c8f716709acdf8de0deddcd6ab
@@ -240,8 +240,8 @@ 
   +a
   
   displaying [PATCH 2 of 2] b ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 2 of 2] b
   X-Mercurial-Node: 97d72e5f12c7e84f85064aa72e5a297142c36ed9
@@ -336,8 +336,8 @@ 
   Cc: bar
   
   --===*= (glob)
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   
   a multiline
@@ -381,8 +381,8 @@ 
   Cc: bar
   
   --===*= (glob)
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   
   a multiline
@@ -414,8 +414,8 @@ 
   
   
   displaying [PATCH] utf-8 content ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 8bit
   Subject: [PATCH] utf-8 content
   X-Mercurial-Node: 909a00e13e9d78b575aeee23dddbada46d5a143f
@@ -460,8 +460,8 @@ 
 
   $ cat mbox
   From quux ... ... .. ..:..:.. .... (re)
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="utf-8"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: base64
   Subject: [PATCH] utf-8 content
   X-Mercurial-Node: 909a00e13e9d78b575aeee23dddbada46d5a143f
@@ -522,8 +522,8 @@ 
   
   
   displaying [PATCH] long line ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: quoted-printable
   Subject: [PATCH] long line
   X-Mercurial-Node: a2ea8fc83dd8b93cfd86ac97b28287204ab806e1
@@ -576,8 +576,8 @@ 
   sending [PATCH] long line ...
   $ cat mbox
   From quux ... ... .. ..:..:.. .... (re)
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: quoted-printable
   Subject: [PATCH] long line
   X-Mercurial-Node: a2ea8fc83dd8b93cfd86ac97b28287204ab806e1
@@ -638,8 +638,8 @@ 
   sending [PATCH] isolatin 8-bit encoding ...
   $ cat mbox
   From quux ... ... .. ..:..:.. .... (re)
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="iso-8859-1"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: quoted-printable
   Subject: [PATCH] isolatin 8-bit encoding
   X-Mercurial-Node: 240fb913fc1b7ff15ddb9f33e73d82bf5277c720
@@ -686,8 +686,8 @@ 
   are you sure you want to send (yn)? y
   
   displaying [PATCH] test ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH] test
   X-Mercurial-Node: ff2c9fa2018b15fa74b33363bda9527323e2a99f
@@ -748,8 +748,8 @@ 
   are you sure you want to send (yn)? y
   
   displaying [PATCH 0 of 2] test ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 0 of 2] test
   Message-Id: <patchbomb.60@*> (glob)
@@ -765,8 +765,8 @@ 
    2 files changed, 2 insertions(+), 0 deletions(-)
   
   displaying [PATCH 1 of 2] a ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 1 of 2] a
   X-Mercurial-Node: 8580ff50825a50c8f716709acdf8de0deddcd6ab
@@ -801,8 +801,8 @@ 
   +a
   
   displaying [PATCH 2 of 2] b ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 2 of 2] b
   X-Mercurial-Node: 97d72e5f12c7e84f85064aa72e5a297142c36ed9
@@ -858,8 +858,8 @@ 
   Cc: bar
   
   --===*= (glob)
+  MIME-Version: 1.0
   Content-Type: text/x-patch; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Content-Disposition: inline; filename=t2.patch
   
@@ -901,8 +901,8 @@ 
   Cc: bar
   
   --===*= (glob)
+  MIME-Version: 1.0
   Content-Type: text/x-patch; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: quoted-printable
   Content-Disposition: inline; filename=t2.patch
   
@@ -948,8 +948,8 @@ 
   
   
   displaying [PATCH 0 of 3] test ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 0 of 3] test
   Message-Id: <patchbomb.60@*> (glob)
@@ -978,8 +978,8 @@ 
   Cc: bar
   
   --===*= (glob)
+  MIME-Version: 1.0
   Content-Type: text/x-patch; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Content-Disposition: inline; filename=t2-1.patch
   
@@ -1016,8 +1016,8 @@ 
   Cc: bar
   
   --===*= (glob)
+  MIME-Version: 1.0
   Content-Type: text/x-patch; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Content-Disposition: inline; filename=t2-2.patch
   
@@ -1054,8 +1054,8 @@ 
   Cc: bar
   
   --===*= (glob)
+  MIME-Version: 1.0
   Content-Type: text/x-patch; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: quoted-printable
   Content-Disposition: inline; filename=t2-3.patch
   
@@ -1112,17 +1112,17 @@ 
   Cc: bar
   
   --===*= (glob)
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
+  Content-Transfer-Encoding: 7bit
+  
+  Patch subject is complete summary.
+  
+  
+  
+  --===*= (glob)
   MIME-Version: 1.0
-  Content-Transfer-Encoding: 7bit
-  
-  Patch subject is complete summary.
-  
-  
-  
-  --===*= (glob)
   Content-Type: text/x-patch; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Content-Disposition: attachment; filename=t2.patch
   
@@ -1163,17 +1163,17 @@ 
   Cc: bar
   
   --===*= (glob)
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
+  Content-Transfer-Encoding: 7bit
+  
+  Patch subject is complete summary.
+  
+  
+  
+  --===*= (glob)
   MIME-Version: 1.0
-  Content-Transfer-Encoding: 7bit
-  
-  Patch subject is complete summary.
-  
-  
-  
-  --===*= (glob)
   Content-Type: text/x-patch; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: quoted-printable
   Content-Disposition: attachment; filename=t2.patch
   
@@ -1230,8 +1230,8 @@ 
   Cc: bar
   
   --===*= (glob)
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   
   # HG changeset patch
@@ -1249,8 +1249,8 @@ 
   +c
   
   --===*= (glob)
+  MIME-Version: 1.0
   Content-Type: text/x-patch; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Content-Disposition: attachment; filename=t2.patch
   
@@ -1280,8 +1280,8 @@ 
   
   
   displaying [PATCH 0 of 3] test ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 0 of 3] test
   Message-Id: <patchbomb.60@*> (glob)
@@ -1310,17 +1310,17 @@ 
   Cc: bar
   
   --===*= (glob)
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
+  Content-Transfer-Encoding: 7bit
+  
+  Patch subject is complete summary.
+  
+  
+  
+  --===*= (glob)
   MIME-Version: 1.0
-  Content-Transfer-Encoding: 7bit
-  
-  Patch subject is complete summary.
-  
-  
-  
-  --===*= (glob)
   Content-Type: text/x-patch; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Content-Disposition: attachment; filename=t2-1.patch
   
@@ -1357,17 +1357,17 @@ 
   Cc: bar
   
   --===*= (glob)
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
+  Content-Transfer-Encoding: 7bit
+  
+  Patch subject is complete summary.
+  
+  
+  
+  --===*= (glob)
   MIME-Version: 1.0
-  Content-Transfer-Encoding: 7bit
-  
-  Patch subject is complete summary.
-  
-  
-  
-  --===*= (glob)
   Content-Type: text/x-patch; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Content-Disposition: attachment; filename=t2-2.patch
   
@@ -1404,17 +1404,17 @@ 
   Cc: bar
   
   --===*= (glob)
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
+  Content-Transfer-Encoding: 7bit
+  
+  Patch subject is complete summary.
+  
+  
+  
+  --===*= (glob)
   MIME-Version: 1.0
-  Content-Transfer-Encoding: 7bit
-  
-  Patch subject is complete summary.
-  
-  
-  
-  --===*= (glob)
   Content-Type: text/x-patch; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: quoted-printable
   Content-Disposition: attachment; filename=t2-3.patch
   
@@ -1460,8 +1460,8 @@ 
   
   
   displaying [PATCH 0 of 1] test ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 0 of 1] test
   Message-Id: <patchbomb.60@*> (glob)
@@ -1473,8 +1473,8 @@ 
   
   
   displaying [PATCH 1 of 1] c ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 1 of 1] c
   X-Mercurial-Node: ff2c9fa2018b15fa74b33363bda9527323e2a99f
@@ -1513,8 +1513,8 @@ 
   
   
   displaying [PATCH 0 of 1] test ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 0 of 1] test
   Message-Id: <patchbomb.60@*> (glob)
@@ -1527,8 +1527,8 @@ 
   foo
   
   displaying [PATCH 1 of 1] c ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 1 of 1] c
   X-Mercurial-Node: ff2c9fa2018b15fa74b33363bda9527323e2a99f
@@ -1569,8 +1569,8 @@ 
   
   
   displaying [PATCH 0 of 2] test ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 0 of 2] test
   Message-Id: <patchbomb.60@*> (glob)
@@ -1582,8 +1582,8 @@ 
   
   
   displaying [PATCH 1 of 2] a ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 1 of 2] a
   X-Mercurial-Node: 8580ff50825a50c8f716709acdf8de0deddcd6ab
@@ -1614,8 +1614,8 @@ 
   +a
   
   displaying [PATCH 2 of 2] b ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 2 of 2] b
   X-Mercurial-Node: 97d72e5f12c7e84f85064aa72e5a297142c36ed9
@@ -1653,8 +1653,8 @@ 
   
   
   displaying [PATCH] test ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH] test
   X-Mercurial-Node: ff2c9fa2018b15fa74b33363bda9527323e2a99f
@@ -1691,8 +1691,8 @@ 
   
   
   displaying [PATCH] test ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH] test
   X-Mercurial-Node: ff2c9fa2018b15fa74b33363bda9527323e2a99f
@@ -1749,8 +1749,8 @@ 
   Cc: bar
   
   --===*= (glob)
+  MIME-Version: 1.0
   Content-Type: text/x-patch; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Content-Disposition: inline; filename=two.diff
   
@@ -1780,8 +1780,8 @@ 
   
   
   displaying [PATCH 0 of 2] test ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 0 of 2] test
   Message-Id: <patchbomb.60@*> (glob)
@@ -1810,8 +1810,8 @@ 
   Cc: bar
   
   --===*= (glob)
+  MIME-Version: 1.0
   Content-Type: text/x-patch; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Content-Disposition: inline; filename=t2-1.patch
   
@@ -1848,8 +1848,8 @@ 
   Cc: bar
   
   --===*= (glob)
+  MIME-Version: 1.0
   Content-Type: text/x-patch; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Content-Disposition: inline; filename=one.patch
   
@@ -1877,8 +1877,8 @@ 
   
   
   displaying [PATCH] Added tag two, two.diff for changeset ff2c9fa2018b ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH] Added tag two, two.diff for changeset ff2c9fa2018b
   X-Mercurial-Node: 7aead2484924c445ad8ce2613df91f52f9e502ed
@@ -1920,8 +1920,8 @@ 
   (optional) Subject: [PATCH 0 of 2] 
   
   displaying [PATCH 1 of 2] a ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 1 of 2] a
   X-Mercurial-Node: 8580ff50825a50c8f716709acdf8de0deddcd6ab
@@ -1952,8 +1952,8 @@ 
   +a
   
   displaying [PATCH 2 of 2] b ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 2 of 2] b
   X-Mercurial-Node: 97d72e5f12c7e84f85064aa72e5a297142c36ed9
@@ -1995,8 +1995,8 @@ 
   
   
   displaying [PATCH 0 of 2] test ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 0 of 2] test
   Message-Id: <patchbomb.60@*> (glob)
@@ -2010,8 +2010,8 @@ 
   
   
   displaying [PATCH 1 of 2] a ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 1 of 2] a
   X-Mercurial-Node: 8580ff50825a50c8f716709acdf8de0deddcd6ab
@@ -2042,8 +2042,8 @@ 
   +a
   
   displaying [PATCH 2 of 2] b ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 2 of 2] b
   X-Mercurial-Node: 97d72e5f12c7e84f85064aa72e5a297142c36ed9
@@ -2083,8 +2083,8 @@ 
   
   
   displaying [PATCH fooFlag] test ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH fooFlag] test
   X-Mercurial-Node: ff2c9fa2018b15fa74b33363bda9527323e2a99f
@@ -2124,8 +2124,8 @@ 
   
   
   displaying [PATCH 0 of 2 fooFlag] test ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 0 of 2 fooFlag] test
   Message-Id: <patchbomb.60@*> (glob)
@@ -2137,8 +2137,8 @@ 
   
   
   displaying [PATCH 1 of 2 fooFlag] a ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 1 of 2 fooFlag] a
   X-Mercurial-Node: 8580ff50825a50c8f716709acdf8de0deddcd6ab
@@ -2169,8 +2169,8 @@ 
   +a
   
   displaying [PATCH 2 of 2 fooFlag] b ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 2 of 2 fooFlag] b
   X-Mercurial-Node: 97d72e5f12c7e84f85064aa72e5a297142c36ed9
@@ -2210,8 +2210,8 @@ 
   
   
   displaying [PATCH fooFlag barFlag] test ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH fooFlag barFlag] test
   X-Mercurial-Node: ff2c9fa2018b15fa74b33363bda9527323e2a99f
@@ -2250,8 +2250,8 @@ 
   
   
   displaying [PATCH 0 of 2 fooFlag barFlag] test ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 0 of 2 fooFlag barFlag] test
   Message-Id: <patchbomb.60@*> (glob)
@@ -2263,8 +2263,8 @@ 
   
   
   displaying [PATCH 1 of 2 fooFlag barFlag] a ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 1 of 2 fooFlag barFlag] a
   X-Mercurial-Node: 8580ff50825a50c8f716709acdf8de0deddcd6ab
@@ -2295,8 +2295,8 @@ 
   +a
   
   displaying [PATCH 2 of 2 fooFlag barFlag] b ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 2 of 2 fooFlag barFlag] b
   X-Mercurial-Node: 97d72e5f12c7e84f85064aa72e5a297142c36ed9
@@ -2337,8 +2337,8 @@ 
   sending [PATCH] test ...
   $ cat < tmp.mbox
   From quux ... ... .. ..:..:.. .... (re)
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH] test
   X-Mercurial-Node: 8580ff50825a50c8f716709acdf8de0deddcd6ab
@@ -2379,8 +2379,8 @@ 
   Cc: 
   
   displaying [PATCH 0 of 2 R1] test ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 0 of 2 R1] test
   Message-Id: <patchbomb.60@*> (glob)
@@ -2392,8 +2392,8 @@ 
   foo
   
   displaying [PATCH 1 of 2 R0] a ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 1 of 2 R0] a
   X-Mercurial-Node: 8580ff50825a50c8f716709acdf8de0deddcd6ab
@@ -2423,8 +2423,8 @@ 
   +a
   
   displaying [PATCH 2 of 2 R1] b ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 2 of 2 R1] b
   X-Mercurial-Node: 97d72e5f12c7e84f85064aa72e5a297142c36ed9
@@ -2462,8 +2462,8 @@ 
   Cc: 
   
   displaying [PATCH default V2] a ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH default V2] a
   X-Mercurial-Node: 8580ff50825a50c8f716709acdf8de0deddcd6ab
@@ -2504,8 +2504,8 @@ 
 
   $ cat tmp.mbox
   From quux ... ... .. ..:..:.. .... (re)
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH] test
   X-Mercurial-Node: 8580ff50825a50c8f716709acdf8de0deddcd6ab
@@ -2582,8 +2582,8 @@ 
   Cc: 
   
   displaying [PATCH 0 of 6] test ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 0 of 6] test
   Message-Id: <patchbomb.315532860@*> (glob)
@@ -2594,8 +2594,8 @@ 
   
   
   displaying [PATCH 1 of 6] c ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 1 of 6] c
   X-Mercurial-Node: ff2c9fa2018b15fa74b33363bda9527323e2a99f
@@ -2625,8 +2625,8 @@ 
   +c
   
   displaying [PATCH 2 of 6] utf-8 content ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 8bit
   Subject: [PATCH 2 of 6] utf-8 content
   X-Mercurial-Node: 909a00e13e9d78b575aeee23dddbada46d5a143f
@@ -2663,8 +2663,8 @@ 
   +h\xc3\xb6mma! (esc)
   
   displaying [PATCH 3 of 6] long line ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: quoted-printable
   Subject: [PATCH 3 of 6] long line
   X-Mercurial-Node: a2ea8fc83dd8b93cfd86ac97b28287204ab806e1
@@ -2710,8 +2710,8 @@ 
   +bar
   
   displaying [PATCH 4 of 6] isolatin 8-bit encoding ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 8bit
   Subject: [PATCH 4 of 6] isolatin 8-bit encoding
   X-Mercurial-Node: 240fb913fc1b7ff15ddb9f33e73d82bf5277c720
@@ -2741,8 +2741,8 @@ 
   +h\xf6mma! (esc)
   
   displaying [PATCH 5 of 6] Added tag zero, zero.foo for changeset 8580ff50825a ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 5 of 6] Added tag zero, zero.foo for changeset 8580ff50825a
   X-Mercurial-Node: 5d5ef15dfe5e7bd3a4ee154b5fff76c7945ec433
@@ -2773,8 +2773,8 @@ 
   +8580ff50825a50c8f716709acdf8de0deddcd6ab zero.foo
   
   displaying [PATCH 6 of 6] d ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 6 of 6] d
   X-Mercurial-Node: 2f9fa9b998c5fe3ac2bd9a2b14bfcbeecbc7c268
@@ -2818,8 +2818,8 @@ 
   
   
   displaying [PATCH] test ...
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH] test
   X-Mercurial-Node: 2f9fa9b998c5fe3ac2bd9a2b14bfcbeecbc7c268
@@ -2953,8 +2953,8 @@ 
   warning: invalid patchbomb.intro value "mpmwearaclownnose"
   (should be one of always, never, auto)
   -f test foo
+  MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
-  MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH] test
   X-Mercurial-Node: 3b6f1ec9dde933a40a115a7990f8b320477231af