From e588ba0d5598d79bd58e1557f10b42ff87345339 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Thu, 9 Apr 2020 17:35:50 -0400 Subject: Trim angle brackets from message IDs --- archive.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'archive.c') diff --git a/archive.c b/archive.c index 497b5a6..889f253 100644 --- a/archive.c +++ b/archive.c @@ -115,6 +115,15 @@ static struct AddressList parseAddressList(struct List list) { return (struct AddressList) { list.len, addrs }; } +static char *parseID(char *id) { + size_t len = strlen(id); + if (id[0] != '<' || !len || id[len - 1] != '>') { + errx(EX_PROTOCOL, "invalid message ID"); + } + id[len - 1] = '\0'; + return &id[1]; +} + static struct Envelope parseEnvelope(struct List list) { enum { Date, Subject, From, Sender, ReplyTo, @@ -162,12 +171,12 @@ static struct Envelope parseEnvelope(struct List list) { envelope.bcc = parseAddressList(list.ptr[Bcc].list); if (list.ptr[InReplyTo].type == String) { - envelope.inReplyTo = list.ptr[InReplyTo].string; + envelope.inReplyTo = parseID(list.ptr[InReplyTo].string); } if (list.ptr[MessageID].type != String) { errx(EX_PROTOCOL, "invalid envelope message-id field"); } - envelope.messageID = list.ptr[MessageID].string; + envelope.messageID = parseID(list.ptr[MessageID].string); return envelope; } -- cgit 1.4.1