[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [flashproxy/js] Replace all pluses in a query string with spaces.



commit 11b2a575d4e4ada56384b85b2b7b9918c10317e7
Author: David Fifield <david@xxxxxxxxxxxxxxx>
Date:   Wed Mar 14 20:27:12 2012 -0700

    Replace all pluses in a query string with spaces.
    
    The argument to replace is a regular expression, so unless you provide
    the 'g' flag it replaces only the first match.
---
 flashproxy-test.js |    2 ++
 flashproxy.js      |    4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/flashproxy-test.js b/flashproxy-test.js
index 1073bab..0f1ac3f 100755
--- a/flashproxy-test.js
+++ b/flashproxy-test.js
@@ -74,6 +74,8 @@ function test_parse_query_string()
           expected: { "a": "b c+d" } },
         { qs: "a+b=c",
           expected: { "a b": "c" } },
+        { qs: "a=b+c+d",
+          expected: { a: "b c d" } },
         /* First appearance wins. */
         { qs: "a=b&c=d&a=e",
           expected: { a: "b", c: "d" } },
diff --git a/flashproxy.js b/flashproxy.js
index 65c6ea2..ae31484 100644
--- a/flashproxy.js
+++ b/flashproxy.js
@@ -43,8 +43,8 @@ function parse_query_string(qs)
             name = string.substr(0, j);
             value = string.substr(j + 1);
         }
-        name = decodeURIComponent(name.replace(/\+/, " "));
-        value = decodeURIComponent(value.replace(/\+/, " "));
+        name = decodeURIComponent(name.replace(/\+/g, " "));
+        value = decodeURIComponent(value.replace(/\+/g, " "));
         if (!(name in result))
              result[name] = value;
     }

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits