about summary refs log tree commit diff
path: root/parse.c
diff options
context:
space:
mode:
authorC. McEnroe <june@causal.agency>2020-04-14 11:07:33 -0400
committerC. McEnroe <june@causal.agency>2020-04-14 11:07:33 -0400
commit8f6d0a2c1c54542ec32a627054bfe1d015480c87 (patch)
tree7410ba416a2e7b4641320c34c9beccb146673932 /parse.c
parentUse mid: URLs for Atom IDs (diff)
downloadbubger-8f6d0a2c1c54542ec32a627054bfe1d015480c87.tar.gz
bubger-8f6d0a2c1c54542ec32a627054bfe1d015480c87.zip
Add decoding stubs
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/parse.c b/parse.c
index ff97789..d491e53 100644
--- a/parse.c
+++ b/parse.c
@@ -29,9 +29,7 @@ static struct Address parseAddress(struct List list) {
 	}
 	struct Address addr = {0};
 	if (list.ptr[0].type == String) {
-		// TODO: Decode UTF-8 in name.
-		addr.name = strdup(list.ptr[0].string);
-		if (!addr.name) err(EX_OSERR, "strdup");
+		addr.name = decodeHeader(list.ptr[0].string);
 	}
 	if (list.ptr[2].type == String) addr.mailbox = list.ptr[2].string;
 	if (list.ptr[3].type == String) addr.host = list.ptr[3].string;
@@ -83,9 +81,9 @@ void parseEnvelope(struct Envelope *envelope, struct List list) {
 	if (!date) errx(EX_PROTOCOL, "invalid envelope date format");
 	envelope->time = mktime(&time);
 
-	// TODO: Decode UTF-8 in subject.
-	envelope->subject = strdup(dataCheck(list.ptr[Subject], String).string);
-	if (!envelope->subject) err(EX_OSERR, "strdup");
+	envelope->subject = decodeHeader(
+		dataCheck(list.ptr[Subject], String).string
+	);
 
 	for (size_t i = From; i <= Bcc; ++i) {
 		if (list.ptr[i].type == List) continue;