summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--decode.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/decode.c b/decode.c
index a106c9c..24de9d3 100644
--- a/decode.c
+++ b/decode.c
@@ -86,16 +86,21 @@ static void convertCharset(
 	iconv_close(conv);
 }
 
+static const char Base64[64] = {
+	"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
+};
+
 static uint8_t unbase64(char ch) {
-	static const char Base64[64] = {
-		"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
-	};
 	const char *ptr = strchr(Base64, ch);
 	return (ptr ? ptr - Base64 : 0);
 }
 
 static void decodeBase64(struct Buffer *dst, const char *src) {
 	while (src[0] && src[1] && src[2] && src[3]) {
+		if (!strchr(Base64, src[0])) {
+			src++;
+			continue;
+		}
 		uint32_t bits = 0;
 		for (int i = 0; i < 4; ++i) {
 			bits <<= 6;