summaryrefslogtreecommitdiff
path: root/src/c
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2010-05-18 14:47:56 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2010-05-18 14:47:56 -0400
commitf2007435ca9e15257cb80085edcbf7f897993f64 (patch)
tree3e8963a10acbb1574ae8f981a1fe663684ab82f2 /src/c
parent46d21ab45cdc23c45296e1e336b7dbbf00849c56 (diff)
URL-escape with '.' instead of '%', to avoid confusing proxies
Diffstat (limited to 'src/c')
-rw-r--r--src/c/urweb.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/c/urweb.c b/src/c/urweb.c
index 6815c85b..141aa06b 100644
--- a/src/c/urweb.c
+++ b/src/c/urweb.c
@@ -1687,7 +1687,7 @@ char *uw_Basis_urlifyString(uw_context ctx, uw_Basis_string s) {
else if (isalnum(c))
*p++ = c;
else {
- sprintf(p, "%%%02X", c);
+ sprintf(p, ".%02X", c);
p += 3;
}
}
@@ -1764,7 +1764,7 @@ uw_unit uw_Basis_urlifyString_w(uw_context ctx, uw_Basis_string s) {
else if (isalnum(c))
uw_writec_unsafe(ctx, c);
else {
- sprintf(ctx->page.front, "%%%02X", c);
+ sprintf(ctx->page.front, ".%02X", c);
ctx->page.front += 3;
}
}
@@ -1822,7 +1822,7 @@ static uw_Basis_string uw_unurlifyString_to(int fromClient, uw_context ctx, char
if (!fromClient) {
if (*s2 == '_')
++s2;
- else if (s2[0] == '%' && s2[1] == '5' && (s2[2] == 'f' || s2[2] == 'F'))
+ else if ((s2[0] == '%' || s2[0] == '.') && s2[1] == '5' && (s2[2] == 'f' || s2[2] == 'F'))
s2 += 3;
}
@@ -1843,6 +1843,18 @@ static uw_Basis_string uw_unurlifyString_to(int fromClient, uw_context ctx, char
*s1 = n;
s2 += 2;
break;
+ case '.':
+ if (!fromClient) {
+ if (s2[1] == 0)
+ uw_error(ctx, FATAL, "Missing first character of escaped URL byte");
+ if (s2[2] == 0)
+ uw_error(ctx, FATAL, "Missing second character of escaped URL byte");
+ if (sscanf(s2+1, "%02X", &n) != 1)
+ uw_error(ctx, FATAL, "Invalid escaped URL byte starting at: %s", s2);
+ *s1 = n;
+ s2 += 2;
+ break;
+ }
default:
*s1 = c;
}