summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2016-09-02 07:18:54 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2016-09-02 07:22:57 (GMT)
commit1fdb8783ce746532b2b8f06877e450c4dad79552 (patch)
tree49e846cd3bcb189e8146a3d1c4dc64c38e651f25
parente61e5a5381511b621826e42608a4d9de3ff57fdc (diff)
downloadmail2redmine-1fdb8783ce746532b2b8f06877e450c4dad79552.zip
mail2redmine-1fdb8783ce746532b2b8f06877e450c4dad79552.tar.gz
mail2redmine-1fdb8783ce746532b2b8f06877e450c4dad79552.tar.bz2
ignore empty attachments (#13022)
-rw-r--r--mail2redmine.py2
-rw-r--r--mail_dumps/ea7b9a42-a03e-4810-b94f-49d42ec5d33f.mail109
2 files changed, 111 insertions, 0 deletions
diff --git a/mail2redmine.py b/mail2redmine.py
index d469354..85c69ef 100644
--- a/mail2redmine.py
+++ b/mail2redmine.py
@@ -39,6 +39,8 @@ def parse_header(header_text):
def parse_attachment(data):
file_data = data.get_payload(decode=True)
+ if not file_data:
+ return None
with tempfile.NamedTemporaryFile(delete=False) as attachment:
attachment.write(file_data)
attachment.flush()
diff --git a/mail_dumps/ea7b9a42-a03e-4810-b94f-49d42ec5d33f.mail b/mail_dumps/ea7b9a42-a03e-4810-b94f-49d42ec5d33f.mail
new file mode 100644
index 0000000..fffcc60
--- /dev/null
+++ b/mail_dumps/ea7b9a42-a03e-4810-b94f-49d42ec5d33f.mail
@@ -0,0 +1,109 @@
+From pcros@entrouvert.com Fri Sep 02 08:56:14 2016
+Received: from 94-224-197-102.access.telenet.be ([94.224.197.102] helo=[192.168.0.156])
+ by leucas.entrouvert.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
+ (Exim 4.80)
+ (envelope-from <pcros@entrouvert.com>)
+ id 1bfiOb-002FXU-LX
+ for support-abcde@entrouvert.com; Fri, 02 Sep 2016 08:56:14 +0200
+Message-ID: <1472799368.3621.365.camel@entrouvert.com>
+From: Pierre Cros <pcros@entrouvert.com>
+To: support-abcde <support-abcde@entrouvert.com>
+Date: Fri, 02 Sep 2016 08:56:08 +0200
+References:
+ <OF2DD06192.554B99C0-ONC1258022.00241E1F-C1258022.00257A09@grand-abcde.org>
+Content-Type: multipart/mixed; boundary="=-b3IEZTNC+auAcdh2k/bK"
+X-Mailer: Evolution 3.20.5-1
+Mime-Version: 1.0
+X-SA-Exim-Connect-IP: 94.224.197.102
+X-SA-Exim-Mail-From: pcros@entrouvert.com
+X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on
+ leucas.entrouvert.org
+X-Spam-Level:
+X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00,
+ HTML_MESSAGE,TVD_RCVD_IP,T_OBFU_DOC_ATTACH autolearn=ham version=3.3.2
+Subject: [Fwd: A nouveau du code =?ISO-8859-1?Q?re=E7u=5D?=
+X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000)
+X-SA-Exim-Scanned: Yes (on leucas.entrouvert.org)
+Status: RO
+Content-Length: 2643
+Lines: 78
+
+
+--=-b3IEZTNC+auAcdh2k/bK
+Content-Type: text/plain
+Content-Transfer-Encoding: 7bit
+
+
+--=-b3IEZTNC+auAcdh2k/bK
+Content-Disposition: inline
+Content-Description: Message =?ISO-8859-1?Q?transf=E9r=E9?= - A nouveau du
+ code =?ISO-8859-1?Q?re=E7u?=
+Content-Type: message/rfc822
+
+Return-path: <abcde.1234567@mairie-abcde.fr>
+Envelope-to: pcros@entrouvert.com
+Delivery-date: Fri, 02 Sep 2016 08:49:28 +0200
+Received: from mail2.grand-abcde.org ([62.244.71.131])
+ by leucas.entrouvert.org with esmtp (Exim 4.80)
+ (envelope-from <abcde.1234567@mairie-abcde.fr>)
+ id 1bfiI2-002EHv-VM
+ for pcros@entrouvert.com; Fri, 02 Sep 2016 08:49:28 +0200
+To: pcros@entrouvert.com
+MIME-Version: 1.0
+X-KeepSent: 2DD06192:554B99C0-C1258022:00241E1F;
+ type=4; name=$KeepSent
+X-Mailer: IBM Notes Release 9.0.1FP4 June 08, 2015
+Message-ID: <OF2DD06192.554B99C0-ONC1258022.00241E1F-C1258022.00257A09@grand-abcde.org>
+From: abcde.1234567@mairie-abcde.fr
+Date: Fri, 2 Sep 2016 08:49:20 +0200
+X-MIMETrack: Serialize by Router on sdominobal2/SVR/Grand-Nancy(Release
+ 8.5.3FP6|November 21, 2013) at 02/09/2016 08:49:26
+Content-Type: multipart/mixed; boundary="=_mixed 00257A08C1258022_="
+X-SA-Exim-Connect-IP: 62.244.71.131
+X-SA-Exim-Mail-From: abcde.1234567@mairie-abcde.fr
+X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on
+ leucas.entrouvert.org
+X-Spam-Level:
+X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,HTML_MESSAGE,
+ RCVD_IN_DNSWL_NONE,T_OBFU_DOC_ATTACH autolearn=ham version=3.3.2
+Subject: =?ISO-8859-1?Q?A_nouveau__du_code_re=E7u?=
+X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000)
+X-SA-Exim-Scanned: Yes (on leucas.entrouvert.org)
+
+
+--=_mixed 00257A08C1258022_=
+Content-Type: multipart/alternative; boundary="=_alternative 00257A09C1258022_="
+
+
+--=_alternative 00257A09C1258022_=
+Content-Type: message/external-body; access-type=x-mutt-deleted;
+ expiration="Fri, 2 Sep 2016 09:20:07 +0200"; length=782
+
+Content-Type: text/plain; charset="ISO-8859-1"
+Content-Transfer-Encoding: 8bit
+
+
+--=_alternative 00257A09C1258022_=
+Content-Type: message/external-body; access-type=x-mutt-deleted;
+ expiration="Fri, 2 Sep 2016 09:20:07 +0200"; length=1482
+
+Content-Type: text/html; charset="ISO-8859-1"
+Content-Transfer-Encoding: 8bit
+
+
+--=_alternative 00257A09C1258022_=--
+
+--=_mixed 00257A08C1258022_=
+Content-Type: message/external-body; access-type=x-mutt-deleted;
+ expiration="Fri, 2 Sep 2016 09:19:31 +0200"; length=123115
+
+Content-Type: application/octet-stream; name="Exception.doc"
+Content-Disposition: attachment; filename="Exception.doc"
+Content-Transfer-Encoding: base64
+
+
+--=_mixed 00257A08C1258022_=--
+
+--=-b3IEZTNC+auAcdh2k/bK--
+
+