From 403c15f3937e612e8f25e63f65fcee8bec3090e3 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Tue, 8 Sep 2009 14:16:54 -0400 Subject: Fixed URL unescaping in the datauri DPI --- dpi/datauri.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'dpi/datauri.c') diff --git a/dpi/datauri.c b/dpi/datauri.c index d620176b..9f35841b 100644 --- a/dpi/datauri.c +++ b/dpi/datauri.c @@ -15,6 +15,8 @@ #include #include #include +#include +#include #include "../dpip/dpip.h" #include "dpiutil.h" @@ -35,7 +37,19 @@ */ static SockHandler *sh = NULL; +static void b64strip_illegal_chars(unsigned char* str) +{ + unsigned char *p, *s = str; + + MSG("len=%d{%s}\n", strlen((char*)str), str); + for (p = s; (*p = *s); ++s) { + if (isalnum(*p) || strchr("+/=", *p)) + ++p; + } + + MSG("len=%d{%s}\n", strlen((char *)str), str); +} static int b64decode(unsigned char* str) { @@ -255,7 +269,8 @@ static unsigned char *datauri_get_data(char *url, size_t *p_sz) if (p) { ++p; if (is_base64) { - data = (unsigned char *)dStrdup(p); + data = (unsigned char *)Unescape_uri_str(p); + b64strip_illegal_chars(data); *p_sz = (size_t) b64decode(data); } else { data = (unsigned char *)a_Url_decode_hex_str(p, p_sz); -- cgit v1.2.3