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

[tor-commits] [flashproxy/master] Make parse_cookie_string parallel parse_query_string.



commit 905e5eaf1a0e7b4a4e5b8838c169a1ed198fcd87
Author: David Fifield <david@xxxxxxxxxxxxxxx>
Date:   Mon Dec 24 17:53:46 2012 -0800

    Make parse_cookie_string parallel parse_query_string.
---
 proxy/flashproxy.js |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/proxy/flashproxy.js b/proxy/flashproxy.js
index 712ef4e..cf22b8d 100644
--- a/proxy/flashproxy.js
+++ b/proxy/flashproxy.js
@@ -101,21 +101,26 @@ function puts(s) {
    is an object mapping cookies names to values. For a description of the cookie
    string format see http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-8747038 */
 function parse_cookie_string(cookies) {
-    var strings = [];
-    var result = {};
+    var strings;
+    var result;
 
+    result = {};
     if (cookies)
         strings = cookies.split(";");
-
+    else
+        strings = [];
     for (var i = 0; i < strings.length; i++) {
-        var j;
         var string = strings[i];
-
-        while (string[0] === " ")
-            string = string.substr(1);
+        var j, name, value;
 
         j = string.indexOf("=");
-        result[string.substr(0, j)] = string.substr(j + 1);
+        name = string.substr(0, j);
+        value = string.substr(j + 1);
+
+        while (name[0] === " ")
+            name = name.substr(1);
+
+        result[name] = value;
     }
 
     return result;



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