summaryrefslogtreecommitdiffstats
path: root/mail/pyzor/files
diff options
context:
space:
mode:
authormbr <mbr@FreeBSD.org>2006-04-15 09:07:49 +0000
committermbr <mbr@FreeBSD.org>2006-04-15 09:07:49 +0000
commitac0e2a6b53223143c0b7a56a2fe7a67fe23fec85 (patch)
treecfae654bc8e49f6772dfa29522da9fdf5c00cd86 /mail/pyzor/files
parent35abc773bc09240497f98bbaef7b545f835684e7 (diff)
downloadFreeBSD-ports-ac0e2a6b53223143c0b7a56a2fe7a67fe23fec85.zip
FreeBSD-ports-ac0e2a6b53223143c0b7a56a2fe7a67fe23fec85.tar.gz
Handle unknown encodings. Even binary parts are handled now.
Treat empty type as 'text'.
Diffstat (limited to 'mail/pyzor/files')
-rw-r--r--mail/pyzor/files/patch-handle_unknown_encodings96
-rw-r--r--mail/pyzor/files/patch-unknowntype12
2 files changed, 108 insertions, 0 deletions
diff --git a/mail/pyzor/files/patch-handle_unknown_encodings b/mail/pyzor/files/patch-handle_unknown_encodings
new file mode 100644
index 0000000..fa0b5c9
--- /dev/null
+++ b/mail/pyzor/files/patch-handle_unknown_encodings
@@ -0,0 +1,96 @@
+--- lib/pyzor/client.py Sun Sep 8 22:37:15 2002
++++ lib/pyzor/client.py Wed Aug 3 10:58:03 2005
+@@ -466,7 +470,7 @@
+
+ (fp, offsets) = self.get_line_offsets(fp)
+
+- # did we get an empty file?
++ # did we get an empty (parsed output)file?
+ if len(offsets) == 0:
+ return
+
+@@ -662,39 +666,66 @@
+ self.multifile = None
+ self.curfile = None
+
++ # Check if we got a mail or not. Set type to binary if there is no 'From:' header and
++ # type text/plain with encoding 7bit. 7bit is passed trough anyway so nobody cares.
++ if (not msg.has_key("From") and self.type == 'text' and msg.subtype == 'plain' and msg.getencoding() == '7bit'):
++ self.type = 'binary';
++
+ if self.type == 'text':
+ encoding = msg.getencoding()
+- if encoding == '7bit':
+- self.curfile = msg.fp
+- else:
+- self.curfile = tempfile.TemporaryFile()
+- mimetools.decode(msg.fp, self.curfile, encoding)
+- self.curfile.seek(0)
+-
++ self.curfile = msg.fp
++ if encoding != '7bit':
++ # fix bad encoding name
++ if encoding == '8bits':
++ encoding = '8bit'
++ try:
++ newcurfile = tempfile.TemporaryFile()
++ mimetools.decode(msg.fp, newcurfile, encoding)
++ newcurfile.seek(0)
++ self.curfile = newcurfile
++ except:
++ # ignore encoding on errors, pass msg as is
++ pass
++
+ elif self.type == 'multipart':
+ import multifile
+ self.multifile = multifile.MultiFile(msg.fp, seekable=False)
+ self.multifile.push(msg.getparam('boundary'))
+- self.multifile.next()
+- self.curfile = self.__class__(self.multifile)
+-
++ try:
++ self.multifile.next()
++ self.curfile = self.__class__(self.multifile)
++ except:
++ #
++ # Catch multipart decoding errors
++ #
++ fp.seek(0)
++ self.curfile = fp
++ self.type = 'binary'
+
+ if self.type == 'text' or self.type == 'multipart':
+ assert self.curfile is not None
++ elif self.type == 'binary':
++ try:
++ fp.seek(0)
++ except:
++ pass
++ self.curfile = fp
+ else:
+ assert self.curfile is None
+
+
+ def readline(self):
+ l = ''
+- if self.type in ('text', 'multipart'):
+- l = self.curfile.readline()
+-
+- if self.type == 'multipart' and not l and self.multifile.next():
+- self.curfile = self.__class__(self.multifile)
+- # recursion. Could get messy if
+- # we get a bunch of empty multifile parts
+- l = self.readline()
++ try:
++ if self.type in ('text', 'multipart', 'binary'):
++ l = self.curfile.readline()
++ if self.type == 'multipart' and not l and self.multifile.next():
++ self.curfile = self.__class__(self.multifile)
++ # recursion. Could get messy if
++ # we get a bunch of empty multifile parts
++ l = self.readline()
++ except (TypeError, multifile.Error):
++ pass
+ return l
+
+
diff --git a/mail/pyzor/files/patch-unknowntype b/mail/pyzor/files/patch-unknowntype
new file mode 100644
index 0000000..8591be0
--- /dev/null
+++ b/mail/pyzor/files/patch-unknowntype
@@ -0,0 +1,12 @@
+--- lib/pyzor/client.py Tue Aug 23 14:53:09 2005
++++ lib/pyzor/client.py Tue Aug 23 14:51:36 2005
+@@ -693,6 +692,9 @@
+ # type text/plain with encoding 7bit. 7bit is passed trough anyway so nobody cares.
+ if (not msg.has_key("From") and self.type == 'text' and msg.subtype == 'plain' and msg.getencoding() == '7bit'):
+ self.type = 'binary';
++
++ if self.type is '':
++ self.type = 'text';
+
+ if self.type == 'text':
+ encoding = msg.getencoding()
OpenPOWER on IntegriCloud