ponymail-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject incubator-ponymail git commit: archiver traverses multi-part message parts twice
Date Mon, 30 Jan 2017 22:46:58 GMT
Repository: incubator-ponymail
Updated Branches:
  refs/heads/master c9b0b3c4d -> 3883b89ab


archiver traverses multi-part message parts twice

This fixes #359

Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/3883b89a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/3883b89a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/3883b89a

Branch: refs/heads/master
Commit: 3883b89ab5a5ef20f9092a7ee42c8728e29be830
Parents: c9b0b3c
Author: Sebb <sebb@apache.org>
Authored: Mon Jan 30 22:46:40 2017 +0000
Committer: Sebb <sebb@apache.org>
Committed: Mon Jan 30 22:46:40 2017 +0000

----------------------------------------------------------------------
 CHANGELOG.md      |  1 +
 tools/archiver.py | 43 ++++++++++++++-----------------------------
 2 files changed, 15 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/3883b89a/CHANGELOG.md
----------------------------------------------------------------------
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2763b42..0395879 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -137,6 +137,7 @@
 - ES 5.0 no longer supports the write consistency option for index(); archiver fails (#351)
 - Cookie should use httpOnly and Secure (#355)
 - crash in import-mbox when list-id is missing and --lid is not provided (#358)
+- archiver traverses multi-part message parts twice (#359)
 
 
 ## CHANGES in 0.9b:

http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/3883b89a/tools/archiver.py
----------------------------------------------------------------------
diff --git a/tools/archiver.py b/tools/archiver.py
index eafe5a3..f7d7896 100755
--- a/tools/archiver.py
+++ b/tools/archiver.py
@@ -209,35 +209,20 @@ class Archiver(object):
     def msgbody(self, msg):
         body = None
         firstHTML = None
-        if msg.is_multipart():
-            for part in msg.walk():
-                """
-                    find the first body part and the first HTML part
-                    Note: cannot use break here because firstHTML is needed
-                    if len(body) <= 1
-                """
-                try:
-                    if part.is_multipart(): 
-                        for subpart in part.walk():
-                            if not body and subpart.get_content_type() == 'text/plain':
-                                body = subpart.get_payload(decode=True)
-                            if not body and subpart.get_content_type() == 'text/enriched':
-                                body = subpart.get_payload(decode=True)
-                            elif self.html and not firstHTML and subpart.get_content_type()
== 'text/html':
-                                firstHTML = subpart.get_payload(decode=True)
-            
-                    elif not body and part.get_content_type() == 'text/plain':
-                        body = part.get_payload(decode=True)
-                    elif self.html and not firstHTML and part.get_content_type() == 'text/html':
-                        firstHTML = part.get_payload(decode=True)
-                except Exception as err:
-                    print(err)
-        elif msg.get_content_type() == 'text/plain':
-            body = msg.get_payload(decode=True)
-        elif msg.get_content_type() == 'text/enriched':
-            body = msg.get_payload(decode=True)
-        elif self.html and msg.get_content_type() == 'text/html':
-            firstHTML = msg.get_payload(decode=True)
+        for part in msg.walk():
+            """
+                Find the first body part and the first HTML part
+                Note: cannot use break here because firstHTML is needed if len(body) <=
1
+            """
+            try:
+                if not body and part.get_content_type() == 'text/plain':
+                    body = part.get_payload(decode=True)
+                if not body and part.get_content_type() == 'text/enriched':
+                    body = part.get_payload(decode=True)
+                elif self.html and not firstHTML and part.get_content_type() == 'text/html':
+                    firstHTML = part.get_payload(decode=True)
+            except Exception as err:
+                print(err)
             
         # this requires a GPL lib, user will have to install it themselves
         if firstHTML and (not body or len(body) <= 1 or (iBody and str(body).find(str(iBody))
!= -1)):


Mime
View raw message