ref: a4a1a88a70d82facefdd19b66ebc372e28adb146
parent: 7c5ca77a6e4d442b4c026e2cd9e483a692f65def
author: cinap_lenrek <[email protected]>
date: Sat Jun 4 15:10:07 EDT 2016
webfs: less aggressive url normalization; never unescape reserved characters in path/query/fragment
--- a/sys/src/cmd/webfs/url.c
+++ b/sys/src/cmd/webfs/url.c
@@ -8,6 +8,8 @@
#include "dat.h"
#include "fns.h"
+static char reserved[] = "%:/?#[]@!$&'()*+,;=";
+
static int
dhex(char c)
{
@@ -31,7 +33,7 @@
for(r=w=s; x = *r; r++){
if(x == '%' && isxdigit(r[1]) && isxdigit(r[2])){
x = (dhex(r[1])<<4)|dhex(r[2]);
- if(x == 0 || x == '%' || (x > 0x1F && x < 0x7F && strchr(spec, x))){
+ if(spec && strchr(spec, x)){
*w++ = '%';
*w++ = toupper(r[1]);
*w++ = toupper(r[2]);
@@ -328,11 +330,11 @@
free(t);
}
- unescape(u->user, "");
- unescape(u->pass, "");
- unescape(u->path, "/");
- unescape(u->query, "&;=/?#");
- unescape(u->fragment, "");
+ unescape(u->user, nil);
+ unescape(u->pass, nil);
+ unescape(u->path, reserved);
+ unescape(u->query, reserved);
+ unescape(u->fragment, reserved);
mklowcase(u->scheme);
mklowcase(u->host);
mklowcase(u->port);