aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikolaus Schulz <microschulz@web.de>2006-10-12 19:28:30 +0000
committerNikolaus Schulz <microschulz@web.de>2006-10-12 19:28:30 +0000
commit6198341eef64440621c9b587905bc71d64984caf (patch)
tree7d8088b0994a925732f2dc89925c2983e68a4fe7
parent88ef628f20318c9b38c3503a60d589e79cde7c66 (diff)
downloadarchivemail-6198341eef64440621c9b587905bc71d64984caf.tar.gz
archivemail-6198341eef64440621c9b587905bc71d64984caf.tar.bz2
archivemail-6198341eef64440621c9b587905bc71d64984caf.zip
Made From_ mangling work reliably with large messages, too.
-rwxr-xr-xarchivemail.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/archivemail.py b/archivemail.py
index dbb2448..72598d7 100755
--- a/archivemail.py
+++ b/archivemail.py
@@ -335,8 +335,13 @@ class Mbox(mailbox.UnixMailbox):
# The following while loop is about twice as fast in
# practice to 'self.mbox_file.writelines(msg.fp.readlines())'
assert(options.read_buffer_size > 0)
+ linebuf = ""
while 1:
- body = msg.fp.read(options.read_buffer_size)
+ chunk = msg.fp.read(options.read_buffer_size)
+ # Be careful not to break pattern matching
+ splitindex = chunk.rfind(os.linesep)
+ body = linebuf + chunk[:splitindex]
+ linebuf = chunk[splitindex:]
if not body:
break
body = from_re.sub('>From ', body)