From: Simon Schubert <2@0x2c.org> Date: Wed, 7 Dec 2011 11:39:46 +0000 (+0100) Subject: deliver_local: quote "From " more liberally X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fedbe7114e3ea26e2a46f4e001879d429018c1f0;p=people%2Fms%2Fdma.git deliver_local: quote "From " more liberally It seems that when scanning for mails in mbox files, most MUAs just look for lines beginning with "From ", and not only for "From " lines after an empty line. Therefore quote "From " more liberally, and also implement the mboxro format by quoting />*From / lines that have been quoted before. Reported-by: Pierre Frenkiel --- diff --git a/dma.h b/dma.h index a1e4b8c..64ad9e6 100644 --- a/dma.h +++ b/dma.h @@ -77,6 +77,10 @@ #define DMA_ROOT_USER "mail" #define DMA_GROUP "mail" +#ifndef MBOX_STRICT +#define MBOX_STRICT 0 +#endif + struct stritem { SLIST_ENTRY(stritem) next; diff --git a/local.c b/local.c index 694dd84..6a6407e 100644 --- a/local.c +++ b/local.c @@ -214,7 +214,17 @@ retry: goto chop; } - if (hadnl && strncmp(line, "From ", 5) == 0) { + /* + * mboxro processing: + * - escape lines that start with "From " with a > sign. + * - be reversable by escaping lines that contain an arbitrary + * number of > signs, followed by "From ", i.e. />*From / in regexp. + * - strict mbox processing only requires escaping after empty lines, + * yet most MUAs seem to relax this requirement and will treat any + * line starting with "From " as the beginning of a new mail. + */ + if ((!MBOX_STRICT || hadnl) && + strncmp(&line[strspn(line, ">")], "From ", 5) == 0) { const char *gt = ">"; if (write(mbox, gt, 1) != 1) diff --git a/test/quote.rfc2822 b/test/quote.rfc2822 new file mode 100644 index 0000000..f0f52fd --- /dev/null +++ b/test/quote.rfc2822 @@ -0,0 +1,23 @@ +From: test +To: test +Subject: testing! + +From what i can see... + +He came along, +from far away. + +The rabbit comes out +From his rabbit hole. + +Fromtal nudity! + +> From the previous mail + +>From the quote + +From here +From there +>>>From everywhere. + +last line.