diff options
author | Jorge Arellano Cid <jcid@dillo.org> | 2009-09-08 14:16:54 -0400 |
---|---|---|
committer | Jorge Arellano Cid <jcid@dillo.org> | 2009-09-08 14:16:54 -0400 |
commit | 403c15f3937e612e8f25e63f65fcee8bec3090e3 (patch) | |
tree | 52d5d5e2824c3c76127614ed08d54ce2911c226a /dpi/dpiutil.c | |
parent | 5231f9206c6c31ae0d53a5c52d6bb75d3d3b3a9e (diff) |
Fixed URL unescaping in the datauri DPI
Diffstat (limited to 'dpi/dpiutil.c')
-rw-r--r-- | dpi/dpiutil.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/dpi/dpiutil.c b/dpi/dpiutil.c index b1affe95..8edf9ace 100644 --- a/dpi/dpiutil.c +++ b/dpi/dpiutil.c @@ -57,6 +57,28 @@ char *Escape_uri_str(const char *str, const char *p_esc_set) return p; } +/* + * Unescape %XX sequences in a string. + * Return value: a new unescaped string + */ +char *Unescape_uri_str(const char *s) +{ + char *p, *buf = dStrdup(s); + + if (strchr(s, '%')) { + for (p = buf; (*p = *s); ++s, ++p) { + if (*p == '%' && isxdigit(s[1]) && isxdigit(s[2])) { + *p = (isdigit(s[1]) ? (s[1] - '0') : toupper(s[1]) - 'A' + 10)*16; + *p += isdigit(s[2]) ? (s[2] - '0') : toupper(s[2]) - 'A' + 10; + s += 2; + } + } + } + + return buf; +} + + static const char *unsafe_chars = "&<>\"'"; static const char *unsafe_rep[] = { "&", "<", ">", """, "'" }; |