diff options
author | Dan Winship <danw@gnome.org> | 2011-11-12 09:27:33 -0500 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2011-11-12 09:27:33 -0500 |
commit | 226f6382496941a4baea6c1c0d22c8d3aed634a1 (patch) | |
tree | ac70c8162e60e2da495ee4227bfcb2f2497be014 /libsoup/soup-uri.c | |
parent | 05dff333a7f46eb6644d28a4e15398d347b9a523 (diff) | |
download | libsoup-226f6382496941a4baea6c1c0d22c8d3aed634a1.tar.gz |
soup-uri: %-encode non-ASCII characters when parsing URIs
https://bugzilla.gnome.org/show_bug.cgi?id=662806
Diffstat (limited to 'libsoup/soup-uri.c')
-rw-r--r-- | libsoup/soup-uri.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/libsoup/soup-uri.c b/libsoup/soup-uri.c index 1aa801b9..9170feb4 100644 --- a/libsoup/soup-uri.c +++ b/libsoup/soup-uri.c @@ -673,7 +673,7 @@ uri_normalized_copy (const char *part, int length, *d++ = *s; } } else { - if (*s == ' ') + if (!g_ascii_isgraph (*s)) need_fixup = TRUE; *d++ = *s; } @@ -681,16 +681,16 @@ uri_normalized_copy (const char *part, int length, if (need_fixup) { GString *fixed; - char *sp, *p; fixed = g_string_new (NULL); - p = normalized; - while ((sp = strchr (p, ' '))) { - g_string_append_len (fixed, p, sp - p); - g_string_append (fixed, "%20"); - p = sp + 1; + s = (guchar *)normalized; + while (*s) { + if (g_ascii_isgraph (*s)) + g_string_append_c (fixed, *s); + else + g_string_append_printf (fixed, "%%%02X", (int)*s); + s++; } - g_string_append (fixed, p); g_free (normalized); normalized = g_string_free (fixed, FALSE); } |