Bug 1515254 - Loosen restrictive "From "-line matching during mbox->maildir conversions. r=mkmelin
authorBen Campbell <benc@thunderbird.net>
Wed, 25 Mar 2020 12:46:59 +0200
changeset 29065 4a0bd51ee9c0627be85fbe59821f442121c0c30f
parent 29064 b8cc5965aca01d602b082a37414fbb30d432e307
child 29066 8ca637b203363896d542f8921f82a0afb8139d8e
push id17184
push usermkmelin@iki.fi
push dateWed, 25 Mar 2020 10:47:45 +0000
treeherdercomm-central@8ca637b20336 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin
bugs1515254
Bug 1515254 - Loosen restrictive "From "-line matching during mbox->maildir conversions. r=mkmelin
mailnews/base/util/converterWorker.js
--- a/mailnews/base/util/converterWorker.js
+++ b/mailnews/base/util/converterWorker.js
@@ -171,27 +171,31 @@ function mboxToMaildir(mboxPath, maildir
   OS.File.makeDir(curDirPath);
   OS.File.makeDir(tmpDirPath);
 
   const CHUNK_SIZE = 1000000;
   // SAFE_MARGIN is how much to keep back between chunks in order to
   // cope with separator lines which might span chunks.
   const SAFE_MARGIN = 100;
 
-  // A regexp to match mbox separator lines.
-  // We support lines like:
+  // A regexp to match mbox separator lines. Separator lines in the wild can
+  // have all sorts of forms, for example:
+  //
   // "From "
   // "From MAILER-DAEMON Fri Jul  8 12:08:34 2011"
   // "From - Mon Jul 11 12:08:34 2011"
   // "From bob@example.com Fri Jul  8 12:08:34 2011"
-  // we also require a message header on the next line, in order
+  //
+  // So we accept any line beginning with "From " and ignore the rest of it.
+  //
+  // We also require a message header on the next line, in order
   // to better cope with unescaped "From " lines in the message body.
   // note: the first subexpression matches the separator line, so
-  // it can be removed from the input.
-  let sepRE = /^((?:From \r?\n)|(?:From [\S]+ \S{3} \S{3} [ \d]\d \d\d:\d\d:\d\d \d{4}\r?\n))[\x21-\x7E]+:/gm;
+  // that it can be removed from the input.
+  let sepRE = /^(From (?:.*?)\r?\n)[\x21-\x7E]+:/gm;
 
   // Use timestamp as starting name for output messages, incrementing
   // by one for each.
   let ident = Date.now();
   let outFile = null;
 
   /**
    * Helper. Convert a string into a Uint8Array, using no encoding. The low