commit dc3ada6fdc80944ba30d4d09545c5a72ce3ec587
parent f164cbb789a862dc8654b0eface7e916ad89df59
Author: Eli Barzilay <eli@racket-lang.org>
Date: Tue, 24 Nov 2009 06:50:02 +0000
use escape/unescape on the value strings
svn: r17027
original commit: d94903ec535ded18f1e889356c261b792323ff5c
Diffstat:
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/collects/scribble/scribble-common.js b/collects/scribble/scribble-common.js
@@ -42,16 +42,18 @@ function GotoPLTRoot(ver, relative) {
// In the following functions, the `name' argument is assumed to be simple in
// that it doesn't contain anything that isn't plain text in a regexp. (This
-// is because I don't know if there's a JS `regexp-quote' thing). Also, the
-// output value from the Get functions and the input value to the Set functions
-// is not decoded/encoded. Note that `SetArgInURL' mutates the string.
+// is because JS doesn't have a `regexp-quote', easy to hack but not needed
+// here). Also, the output value from the Get functions and the input value to
+// the Set functions is decoded/encoded. Note that `SetArgInURL' mutates the
+// string in the url object.
function GetArgFromString(str, name) {
var rx = new RegExp("(?:^|[;&])"+name+"=([^&;]*)(?:[;&]|$)");
- return rx.test(str) && RegExp.$1;
+ return rx.test(str) && unescape(RegExp.$1);
}
function SetArgInString(str, name, val) {
+ val = escape(val);
if (str.length == 0) return name + "=" + val;
var rx = new RegExp("^((?:|.*[;&])"+name+"=)(?:[^&;]*)([;&].*|)$");
if (rx.test(str)) return RegExp.$1 + val + RegExp.$2;