Mercurial > urweb
diff src/c/urweb.c @ 1259:83b1853d1e58
URL-escape with '.' instead of '%', to avoid confusing proxies
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Tue, 18 May 2010 14:47:56 -0400 |
parents | e80582b927f2 |
children | 236dc296c32d |
line wrap: on
line diff
--- a/src/c/urweb.c Sun May 16 18:25:00 2010 -0400 +++ b/src/c/urweb.c Tue May 18 14:47:56 2010 -0400 @@ -1687,7 +1687,7 @@ else if (isalnum(c)) *p++ = c; else { - sprintf(p, "%%%02X", c); + sprintf(p, ".%02X", c); p += 3; } } @@ -1764,7 +1764,7 @@ 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 @@ 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 @@ *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; }