From: theinicke@bss-wf.de
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 [thread overview]
Message-ID: <FEB70CF14BD53F79E2C893F3AE4542D0@bss-wf.de> (raw)
In-Reply-To: <5021098071C7A58059D67139EDC43A44@eigenstate.org>
> 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*
next prev parent reply other threads:[~2020-09-14 21:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-09 19:33 theinicke
2020-09-09 19:50 ` [9front] " ori
2020-09-10 6:27 ` theinicke
2020-09-10 19:58 ` theinicke
2020-09-10 21:12 ` ori
2020-09-11 21:08 ` theinicke
2020-09-12 21:19 ` theinicke
2020-09-12 22:58 ` ori
2020-09-14 21:49 ` theinicke [this message]
2020-09-17 23:01 ` ori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=FEB70CF14BD53F79E2C893F3AE4542D0@bss-wf.de \
--to=theinicke@bss-wf.de \
--cc=9front@9front.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).