From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from outgoing.selfhost.de ([82.98.87.70]) by ewsd; Mon Sep 14 17:49:27 EDT 2020 Received: (qmail 30724 invoked from network); 14 Sep 2020 21:49:04 -0000 Received: from unknown (HELO mx03.bss-wf.de) (postmaster@emdtgvmf.mail.selfhost.de@84.150.42.130) by mailout.selfhost.de with ESMTPA; 14 Sep 2020 21:49:04 -0000 Received: by mx03.bss-wf.de (Postfix, from userid 1000) id 3D5023DD7C; Mon, 14 Sep 2020 23:49:04 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mx03 X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED autolearn=ham autolearn_force=no version=3.4.2 Received: from 9pi.pala (p5b3bc91e.dip0.t-ipconnect.de [91.59.201.30]) by mx03.bss-wf.de (Postfix) with ESMTPSA id 45F3E3DD7A for <9front@9front.org>; Mon, 14 Sep 2020 23:49:03 +0200 (CEST) Message-ID: To: 9front@9front.org Subject: Re: [9front] [Bug] [PATCH] Mail cannot cope with multi-line header fields Date: Mon, 14 Sep 2020 23:49:01 +0200 From: theinicke@bss-wf.de In-Reply-To: <5021098071C7A58059D67139EDC43A44@eigenstate.org> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: information XML over YAML package reduce/map database framework > I think I like your idea of doing it in copy822. How's this? This is fine except for the potential corner case of having CRLF inside a quoted string in one of the header fields treated by addr822. That is in rfc2855 it says in section 3.2.5 "Since a quoted-string is allowed to contain FWS, folding is permitted.". If we want to follow this path of fixing it here, then I think we also would have to at least amend the condition in /sys/src/cmd/upas/fs/mbox.c:763 (776 after applying your patch). -- Tobias Heinicke diff -r 9f6e77258f69 sys/src/cmd/upas/fs/mbox.c --- a/sys/src/cmd/upas/fs/mbox.c Thu Sep 10 16:26:42 2020 -0700 +++ b/sys/src/cmd/upas/fs/mbox.c Mon Sep 14 23:40:27 2020 +0200 @@ -733,6 +733,19 @@ } static char* +unfold(char *s) +{ + char *p, *q; + + q = s; + for(p = q; *p != '\0'; p++) + if(*p != '\r' && *p != '\n') + *q++ = *p; + *q = '\0'; + return s; +} + +static char* addr822(char *p, char **ac) { int n, c, space, incomment, addrdone, inanticomment, quoted; @@ -760,7 +773,7 @@ for(p++; c = *p; p++){ if(ac && c == '"') break; - if(!addrdone && !incomment) + if(!addrdone && !incomment && c != '\r' && c != '\n') ps = sputc(ps, e, c); if(!quoted && *p == '"') break; @@ -883,7 +896,7 @@ static char* copy822(Message*, Header *h, char*, char *p) { - return rtrim(strdup(skipwhite(p + h->len))); + return rtrim(unfold(strdup(skipwhite(p + h->len)))); } static char*