From 6198341eef64440621c9b587905bc71d64984caf Mon Sep 17 00:00:00 2001 From: Nikolaus Schulz Date: Thu, 12 Oct 2006 19:28:30 +0000 Subject: [PATCH] Made From_ mangling work reliably with large messages, too. --- archivemail.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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)