Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id DC6E0200C0C for ; Mon, 30 Jan 2017 23:47:03 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id D937A160B4D; Mon, 30 Jan 2017 22:47:03 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 2ECFB160B35 for ; Mon, 30 Jan 2017 23:47:03 +0100 (CET) Received: (qmail 99511 invoked by uid 500); 30 Jan 2017 22:47:02 -0000 Mailing-List: contact commits-help@ponymail.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ponymail.incubator.apache.org Delivered-To: mailing list commits@ponymail.incubator.apache.org Received: (qmail 99502 invoked by uid 99); 30 Jan 2017 22:47:02 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 30 Jan 2017 22:47:02 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id D0D85181994 for ; Mon, 30 Jan 2017 22:47:01 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -6.219 X-Spam-Level: X-Spam-Status: No, score=-6.219 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id ZqJgkkv9qEBO for ; Mon, 30 Jan 2017 22:47:00 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id AAF7B5F1C2 for ; Mon, 30 Jan 2017 22:46:59 +0000 (UTC) Received: (qmail 99486 invoked by uid 99); 30 Jan 2017 22:46:58 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 30 Jan 2017 22:46:58 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 800BDDFBDB; Mon, 30 Jan 2017 22:46:58 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sebb@apache.org To: commits@ponymail.incubator.apache.org Message-Id: <859f9177ebf342c6ad98ae8b8b96b487@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: incubator-ponymail git commit: archiver traverses multi-part message parts twice Date: Mon, 30 Jan 2017 22:46:58 +0000 (UTC) archived-at: Mon, 30 Jan 2017 22:47:04 -0000 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 Authored: Mon Jan 30 22:46:40 2017 +0000 Committer: Sebb 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)):