summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-04-09 17:35:50 -0400
committerJune McEnroe <june@causal.agency>2020-04-09 17:35:50 -0400
commite588ba0d5598d79bd58e1557f10b42ff87345339 (patch)
treeb1525da3eb9aeebe1aad0d6fd0f14e87cda15edb
parentExport mbox files (diff)
downloadbubger-e588ba0d5598d79bd58e1557f10b42ff87345339.tar.gz
bubger-e588ba0d5598d79bd58e1557f10b42ff87345339.zip
Trim angle brackets from message IDs
Diffstat (limited to '')
-rw-r--r--archive.c13
1 files changed, 11 insertions, 2 deletions
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;
 }