# HG changeset patch # User Adam Chlipala # Date 1261669493 18000 # Node ID e8143451372070fcd76fd45153a32730b22d72ee # Parent 99aebdf30257eca8102fa534c87e0c488d672c02 Proper JavaScript-side URI escaping/de-escaping; fix C-side URL encoding of big characters diff -r 99aebdf30257 -r e81434513720 lib/js/urweb.js --- a/lib/js/urweb.js Thu Dec 24 10:02:48 2009 -0500 +++ b/lib/js/urweb.js Thu Dec 24 10:44:53 2009 -0500 @@ -583,8 +583,7 @@ function uf(s) { if (s.length == 0) return "_"; - return (s.charAt(0) == '_' ? "_" : "") - + escape(s).replace(new RegExp ("/", "g"), "%2F").replace(new RegExp ("\\+", "g"), "%2B"); + return (s.charAt(0) == '_' ? "_" : "") + encodeURIComponent(s); } function uu(s) { @@ -592,7 +591,7 @@ s = s.substring(1); } else if (s.length >= 3 && s.charAt(0) == '%' && s.charAt(1) == '5' && (s.charAt(2) == 'f' || s.charAt(2) == 'F')) s = s.substring(3); - return unescape(s.replace(new RegExp ("\\+", "g"), " ")); + return decodeURIComponent(s.replace(new RegExp ("\\+", "g"), " ")); } function ub(b) { diff -r 99aebdf30257 -r e81434513720 src/c/urweb.c --- a/src/c/urweb.c Thu Dec 24 10:02:48 2009 -0500 +++ b/src/c/urweb.c Thu Dec 24 10:44:53 2009 -0500 @@ -1590,7 +1590,7 @@ *p++ = '_'; for (; *s; s++) { - char c = *s; + unsigned char c = *s; if (c == ' ') *p++ = '+'; @@ -1667,7 +1667,7 @@ uw_writec_unsafe(ctx, '_'); for (; *s; s++) { - char c = *s; + unsigned char c = *s; if (c == ' ') uw_writec_unsafe(ctx, '+'); @@ -1737,7 +1737,7 @@ } for (s1 = r; *s2; ++s1, ++s2) { - char c = *s2; + unsigned char c = *s2; switch (c) { case '+': diff -r 99aebdf30257 -r e81434513720 tests/jsuni.ur --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/jsuni.ur Thu Dec 24 10:44:53 2009 -0500 @@ -0,0 +1,17 @@ +fun main () = + s1 <- source ""; + s2 <- source ""; + + let + fun echo s = return s + + fun echoer () = + v1 <- get s1; + v1' <- rpc (echo v1); + set s2 v1' + in + return +
+