summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--decode.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/decode.c b/decode.c
index 654cf22..1645a66 100644
--- a/decode.c
+++ b/decode.c
@@ -85,11 +85,30 @@ static void convertCharset(
 	iconv_close(conv);
 }
 
+static void decodeQ(struct Buffer *dst, const char *src, size_t len) {
+	while (len) {
+		if (*src == '=') {
+			if (len < 3) break;
+			*bufferDest(dst, 1) = strtoul(&src[1], NULL, 16);
+			len -= 3;
+			src += 3;
+		} else {
+			*bufferDest(dst, 1) = (*src == '_' ? ' ' : *src);
+			len--;
+			src++;
+		}
+	}
+}
+
 static void decodeEncoding(
 	struct Buffer *dst, const char *encoding, const char *src, size_t len
 ) {
-	// TODO
-	bufferCopy(dst, src, len);
+	if (!strcasecmp(encoding, "Q")) {
+		decodeQ(dst, src, len);
+	} else {
+		// TODO
+		bufferCopy(dst, src, len);
+	}
 }
 
 static void decode(