mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-24 04:56:50 +03:00
Bring percent-encoding closer to what other browsers do.
svn path=/trunk/netsurf/; revision=3179
This commit is contained in:
parent
6ae4b59a4b
commit
d1b79f3e41
21
utils/url.c
21
utils/url.c
@ -74,7 +74,7 @@ bool url_host_is_ip_address(const char *host) {
|
||||
bool n;
|
||||
|
||||
assert(host);
|
||||
|
||||
|
||||
/* an IP address is of the format XXX.XXX.XXX.XXX, ie totally
|
||||
* numeric with 3 full stops between the numbers */
|
||||
b = 0; // number of breaks
|
||||
@ -821,19 +821,24 @@ url_func_result url_escape(const char *unescaped, bool sptoplus,
|
||||
return URL_FUNC_NOMEM;
|
||||
|
||||
for (c = unescaped, d = escaped; *c; c++) {
|
||||
if (!isascii(*c) ||
|
||||
strchr(";/?:@&=+$," "<>#%\"{}|\\^[]`", *c) ||
|
||||
/* Check if we should escape this byte.
|
||||
* '~' is unreserved and should not be percent encoded, if
|
||||
* you believe the spec; however, leaving it unescaped
|
||||
* breaks a bunch of websites, so we escape it anyway. */
|
||||
if (!isascii(*c) || strchr(":/?#[]@" /* gen-delims */
|
||||
"!$&'()*+,;=" /* sub-delims */
|
||||
"<>%\"{}|\\^`~", /* others */
|
||||
*c) ||
|
||||
*c <= 0x20 || *c == 0x7f) {
|
||||
if (*c == 0x20 && sptoplus)
|
||||
if (*c == 0x20 && sptoplus) {
|
||||
*d++ = '+';
|
||||
else {
|
||||
} else {
|
||||
*d++ = '%';
|
||||
*d++ = "0123456789ABCDEF"[((*c >> 4) & 0xf)];
|
||||
*d++ = "0123456789ABCDEF"[(*c & 0xf)];
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* unreserved characters: [a-zA-Z0-9-_.!~*'()] */
|
||||
} else {
|
||||
/* unreserved characters: [a-zA-Z0-9-._] */
|
||||
*d++ = *c;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user