]> git.phdru.name Git - mimedecode.git/commitdiff
Fix a minor bug
authorOleg Broytman <phd@phdru.name>
Mon, 10 Mar 2014 17:26:16 +0000 (21:26 +0400)
committerOleg Broytman <phd@phdru.name>
Mon, 10 Mar 2014 17:30:46 +0000 (21:30 +0400)
If a multipart message (or a subpart) lacks any textual content -
avoid putting an excessive newline.

23 files changed:
ANNOUNCE
mimedecode.py
test/expected/msg_02-1.txt
test/expected/msg_02.txt
test/expected/msg_07.txt
test/expected/msg_08.txt
test/expected/msg_09.txt
test/expected/msg_10.txt
test/expected/msg_12.txt
test/expected/msg_12a.txt
test/expected/msg_13-1.txt
test/expected/msg_13.txt
test/expected/msg_22-1.txt
test/expected/msg_22.txt
test/expected/msg_23.txt
test/expected/msg_24.txt
test/expected/msg_28.txt
test/expected/msg_30.txt
test/expected/msg_34.txt
test/expected/msg_36.txt
test/expected/msg_37.txt
test/expected/msg_38.txt
test/expected/msg_39.txt

index 58e552e7935c6b0d178b69a2b7582aa0621bd407..613982dcf240370063a68bc8a21fe3960ae03ab5 100644 (file)
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -33,6 +33,9 @@ level).
 
    Add option -B to skip content-transfer-decoding binary attachments.
 
+   Fix a minor bug: if a multipart message (or a subpart) lacks any textual
+content - avoid putting an excessive newline.
+
 WHAT'S NEW in version 2.4.0 (2014-03-08)
 
    Change option -d to accept a comma-separated list of headers:
index c12afbb963bcdd60eeaee789d6de8848d8ee1a26..8971efa913688653b57d5f873895ed66156cd952 100755 (executable)
@@ -325,12 +325,19 @@ def decode_multipart(msg):
 
     if msg.preamble: # Preserve the first part, it is probably not a RFC822-message
         output(msg.preamble) # Usually it is just a few lines of text (MIME warning)
+    if msg.preamble is not None:
+        output("\n")
 
+    first_subpart = True
     boundary = msg.get_boundary()
 
     for subpart in msg.get_payload():
         if boundary:
-            output("\n--%s\n" % boundary)
+            if first_subpart:
+                first_subpart = False
+            else:
+                output("\n")
+            output("--%s\n" % boundary)
 
         # Recursively decode all parts of the subpart
         decode_message(subpart)
index 410e9f378f385954126b5448e5f7c8390f29ddb4..f854c3e21093f2190d991c71dec6a61806338d90 100644 (file)
@@ -9,7 +9,6 @@ X-Mailman-Version: 2.0.4
 Content-Type: multipart/mixed; boundary="192.168.1.2.889.32614.987812255.500.21814"
 X-Mailer: Mailman v2.0.4; test="set"
 
-
 --192.168.1.2.889.32614.987812255.500.21814
 Content-description: Masthead (Ppp digest, Vol 1 #2)
 MIME-Version: 1.0
@@ -48,7 +47,6 @@ Today's Topics:
 --192.168.1.2.889.32614.987812255.500.21814
 Content-Type: multipart/digest; boundary="__--__--"
 
-
 --__--__--
 
 Message: 1
index fa2fceea80f940135be04b4e4b0bfff4baa90a46..f12dd124898c1d1d489a75ca196619cb44cb7956 100644 (file)
@@ -9,7 +9,6 @@ X-Mailer: Mailman v2.0.4
 X-Mailman-Version: 2.0.4
 Content-Type: multipart/mixed; boundary="192.168.1.2.889.32614.987812255.500.21814"
 
-
 --192.168.1.2.889.32614.987812255.500.21814
 Content-description: Masthead (Ppp digest, Vol 1 #2)
 MIME-Version: 1.0
@@ -48,7 +47,6 @@ Today's Topics:
 --192.168.1.2.889.32614.987812255.500.21814
 Content-Type: multipart/digest; boundary="__--__--"
 
-
 --__--__--
 
 Message: 1
index 78f67ea078726b1fd469722070ede4f0b3f87aaf..9cfaa68d524a38bb740cc5398d8f440567cd3881 100644 (file)
Binary files a/test/expected/msg_07.txt and b/test/expected/msg_07.txt differ
index 47e4e0cd909af77f5f9243cf53bf808aaa73d7a7..fd966be0660cc2820db55b1c4d76e9d1c1ddce41 100644 (file)
@@ -6,7 +6,6 @@ Subject: Lyrics
 Date: Fri, 20 Apr 2001 19:35:02 -0400
 Content-Type: multipart/mixed; boundary="BOUNDARY"
 
-
 --BOUNDARY
 MIME-Version: 1.0
 Content-Type: text/plain; charset="utf-8"
index 5057f17754c86646b2b35404af983bdc2f9bf0cf..8c8d77386bb3a48cf3771796379eb0495789e6de 100644 (file)
@@ -6,7 +6,6 @@ Subject: Lyrics
 Date: Fri, 20 Apr 2001 19:35:02 -0400
 Content-Type: multipart/mixed; boundary="BOUNDARY"
 
-
 --BOUNDARY
 MIME-Version: 1.0
 Content-Type: text/plain; charset="utf-8"
index 34da8908df7d658637f7cbf2a15f63fa6eb85e34..e59a81be03acc57caba8a82ac49afe52f4e64918 100644 (file)
@@ -6,7 +6,6 @@ Subject: Lyrics
 Date: Fri, 20 Apr 2001 19:35:02 -0400
 Content-Type: multipart/mixed; boundary="BOUNDARY"
 
-
 --BOUNDARY
 Content-Transfer-Encoding: 7bit
 MIME-Version: 1.0
index 36229a0d4b4d22aace880e86ef5f5a3dd40cdc29..e765d019c9d2a856062c709f020d9968669f3cfd 100644 (file)
@@ -6,7 +6,6 @@ Subject: Lyrics
 Date: Fri, 20 Apr 2001 19:35:02 -0400
 Content-Type: multipart/mixed; boundary="BOUNDARY"
 
-
 --BOUNDARY
 MIME-Version: 1.0
 Content-Type: text/plain; charset="utf-8"
@@ -24,7 +23,6 @@ X-MIME-Autoconverted: from iso-8859-1 to utf-8 by test id mimedecode.py
 --BOUNDARY
 Content-Type: multipart/mixed; boundary="ANOTHER"
 
-
 --ANOTHER
 MIME-Version: 1.0
 Content-Type: text/plain; charset="utf-8"
index 1ab7b36a25e29e59942cea92a55c92e149df93a0..9d672831999f38bf16fc6bb62269dc5e89f2f7e5 100644 (file)
@@ -6,7 +6,6 @@ Subject: Lyrics
 Date: Fri, 20 Apr 2001 19:35:02 -0400
 Content-Type: multipart/mixed; boundary="BOUNDARY"
 
-
 --BOUNDARY
 MIME-Version: 1.0
 Content-Type: text/plain; charset="utf-8"
@@ -24,7 +23,6 @@ X-MIME-Autoconverted: from iso-8859-1 to utf-8 by test id mimedecode.py
 --BOUNDARY
 Content-Type: multipart/mixed; boundary="ANOTHER"
 
-
 --ANOTHER
 MIME-Version: 1.0
 Content-Type: text/plain; charset="utf-8"
index e5728bb24235d156b1771a8189a899e503672ac7..5c5ef07c4255b6135eb9ca4e2102e920f22af2d9 100644 (file)
@@ -6,7 +6,6 @@ Subject: Here is your dingus fish
 Date: Fri, 20 Apr 2001 19:35:02 -0400
 Content-Type: multipart/mixed; boundary="OUTER"
 
-
 --OUTER
 Content-Type: text/plain; charset="us-ascii"
 
index a7abbec0cceb9dfcc358762d36526408c52060e4..1e0cdf3a254a99bfac47f0c5ae8a3ad961327f8a 100644 (file)
Binary files a/test/expected/msg_13.txt and b/test/expected/msg_13.txt differ
index 0d58be1347ef26e691de16fdbc6ee49e8e4ea42b..1545c7302a6547d4d460a171936292f396c2c66f 100644 (file)
Binary files a/test/expected/msg_22-1.txt and b/test/expected/msg_22-1.txt differ
index a7b5b3584d04f6905121727c588192fe994bc808..0caea80e2ff2a8e079d5be24dc47d44eea496531 100644 (file)
Binary files a/test/expected/msg_22.txt and b/test/expected/msg_22.txt differ
index ae2e6381da07bebdbf74cbeedd80688a061ea080..ff9dfa842e05c9ee9d251a657ffddf47918308b6 100644 (file)
@@ -2,7 +2,6 @@ From test Sat Feb  1 00:00:00 2014
 From: aperson@dom.ain
 Content-Type: multipart/mixed; boundary="BOUNDARY"
 
-
 --BOUNDARY
 Content-Type: text/plain
 
index eb27f14ba1600ea8006b4b85c4c42a07f2b9e76b..05c255230ae990e43e4a1ca992dc9353d696543c 100644 (file)
@@ -5,7 +5,6 @@ Subject: A subject
 To: aperson@dom.ain
 From: bperson@dom.ain
 
-
 --BOUNDARY
 
 
index bf3272b36154a726d3aad9ec6393d9b31b395b6c..3c6ae18203d3bc66f62b79ba47ee4e023b486e57 100644 (file)
@@ -3,7 +3,6 @@ From: aperson@dom.ain
 MIME-Version: 1.0
 Content-Type: multipart/digest; boundary=BOUNDARY
 
-
 --BOUNDARY
 Content-Type: message/rfc822
 
index deae715ba0b858e16caad9642edd321641a330cb..d75a444815a3a8db49236673c52e46d24b0ff06c 100644 (file)
@@ -3,7 +3,6 @@ From: aperson@dom.ain
 MIME-Version: 1.0
 Content-Type: multipart/digest; boundary=BOUNDARY
 
-
 --BOUNDARY
 
 To: aa@bb.org
index f8826ad1f5365bb5f1f2ddd2f410c7a1c8bc7f3e..110f9f55a2839ddde8cb940e968926db57201f33 100644 (file)
@@ -3,7 +3,6 @@ From: aperson@dom.ain
 To: bperson@dom.ain
 Content-Type: multipart/digest; boundary=XYZ
 
-
 --XYZ
 Content-Type: text/plain
 
index 7ee1898253f326f6e841bab00c77430cda5618d0..48a9d36ee10f2558af55491298f0d9739c39e229 100644 (file)
@@ -6,7 +6,6 @@ From: Internet-Drafts@ietf.org
 Subject: I-D ACTION:draft-ietf-mboned-mix-00.txt
 Date: Tue, 22 Dec 1998 16:55:06 -0500
 
-
 --NextPart
 
 Blah blah blah
@@ -14,7 +13,6 @@ Blah blah blah
 --NextPart
 Content-Type: Multipart/Alternative; Boundary="OtherAccess"
 
-
 --OtherAccess
 Content-Type: Message/External-body;
        access-type="mail-server";
index 0739fdbf0ccfa9f3bd9eec8e2e9e4ce4082ccd92..fc945008bf1e34432075e4ed09e90263ace42ed8 100644 (file)
@@ -1,7 +1,6 @@
 From test Sat Feb  1 00:00:00 2014
 Content-Type: multipart/mixed; boundary=ABCDE
 
-
 --ABCDE
 Content-Type: text/x-one
 
index 3c580c7a59db644b33dfb8507a1f949d96a870f3..a56a754019bda447df14207b1fb36fecbf0e3958 100644 (file)
@@ -2,17 +2,14 @@ From test Sat Feb  1 00:00:00 2014
 MIME-Version: 1.0
 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
 
-
 ------- =_aaaaaaaaaa0
 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa1"
 Content-ID: <20592.1022586929.1@example.com>
 
-
 ------- =_aaaaaaaaaa1
 Content-Type: multipart/alternative; boundary="----- =_aaaaaaaaaa2"
 Content-ID: <20592.1022586929.2@example.com>
 
-
 ------- =_aaaaaaaaaa2
 Content-Type: text/plain
 Content-ID: <20592.1022586929.3@example.com>
index 26b16895676c8fb74b588847df3eb220ecdb1c59..9c99abdbc6871bc5aa63c9224c167e7ff876abb8 100644 (file)
@@ -2,12 +2,10 @@ From test Sat Feb  1 00:00:00 2014
 MIME-Version: 1.0
 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
 
-
 ------- =_aaaaaaaaaa0
 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa1"
 Content-ID: <20592.1022586929.1@example.com>
 
-
 ------- =_aaaaaaaaaa1
 Content-Type: multipart/alternative; boundary="----- =_aaaaaaaaaa1"
 Content-ID: <20592.1022586929.2@example.com>