diff lib/js/urweb.js @ 1087:e81434513720

Proper JavaScript-side URI escaping/de-escaping; fix C-side URL encoding of big characters
author Adam Chlipala <adamc@hcoop.net>
date Thu, 24 Dec 2009 10:44:53 -0500
parents e8a35d710ab9
children 6e5463a53c3c
line wrap: on
line diff
--- 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) {