about summary refs log tree commit diff
path: root/parse.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-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;