From: Magnus Hagander Date: Sat, 5 Jan 2013 13:11:57 +0000 (+0100) Subject: Properly parse attachments of type=text/plain, content-disposition=attachment X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=bc9ab0666c6fd3119c5768c09f44673df9790e9b;p=pgarchives.git Properly parse attachments of type=text/plain, content-disposition=attachment Previously we'd only parse them if they were given an explicit name, which is not required - instead, they can have a filename... --- diff --git a/loader/lib/parser.py b/loader/lib/parser.py index 543a535..033cb1e 100644 --- a/loader/lib/parser.py +++ b/loader/lib/parser.py @@ -297,6 +297,10 @@ class ArchivesParser(object): # Yes, it has a name self.attachments.append((self._extract_filename(container), container.get_content_type(), container.get_payload(decode=True))) return + # If it's content-disposition=attachment, we also want to save it + if container.has_key('Content-Disposition') and container['Content-Disposition'].startswith('attachment'): + self.attachments.append((self._extract_filename(container), container.get_content_type(), container.get_payload(decode=True))) + return # No name, and text/plain, so ignore it re_msgid = re.compile('^\s*<(.*)>\s*')