summaryrefslogtreecommitdiff
path: root/dpi/datauri.c
diff options
context:
space:
mode:
authorJorge Arellano Cid <jcid@dillo.org>2009-09-08 14:16:54 -0400
committerJorge Arellano Cid <jcid@dillo.org>2009-09-08 14:16:54 -0400
commit403c15f3937e612e8f25e63f65fcee8bec3090e3 (patch)
tree52d5d5e2824c3c76127614ed08d54ce2911c226a /dpi/datauri.c
parent5231f9206c6c31ae0d53a5c52d6bb75d3d3b3a9e (diff)
Fixed URL unescaping in the datauri DPI
Diffstat (limited to 'dpi/datauri.c')
-rw-r--r--dpi/datauri.c17
1 files changed, 16 insertions, 1 deletions
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 <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <ctype.h>
+#include <errno.h>
#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);