*d++ = *s;
}
} else {
- if (*s == ' ')
+ if (!g_ascii_isgraph (*s))
need_fixup = TRUE;
*d++ = *s;
}
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);
}
{ "http://host/path%%%", "http://host/path%%%" },
{ "http://host/path%/x/", "http://host/path%/x/" },
{ "http://host/path%0x/", "http://host/path%0x/" },
- { "http://host/path%ax", "http://host/path%ax" }
+ { "http://host/path%ax", "http://host/path%ax" },
+
+ /* Bug 662806; %-encode non-ASCII characters */
+ { "http://host/p\xc3\xa4th/", "http://host/p%C3%A4th/" }
};
static int num_abs_tests = G_N_ELEMENTS(abs_tests);