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

[tor-commits] [flashproxy/master] Handle equal signs in cookie values correctly.



commit 4318c560e094f78cf94717502fbad737dc426ebb
Author: Alexandre Allaire <alexandre.allaire@xxxxxxxxxxxxxx>
Date:   Fri Dec 21 19:11:17 2012 -0500

    Handle equal signs in cookie values correctly.
    
    The previous version split on the "=" character, and took
    the second element in the split as the cookie value. This
    will truncate cookie values with equal signs in them. The
    correct approach is to take everything after the first "="
    as the value.
---
 proxy/options.html |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/proxy/options.html b/proxy/options.html
index 1126850..59f0125 100644
--- a/proxy/options.html
+++ b/proxy/options.html
@@ -84,18 +84,18 @@ function set_cookie_disallowed() {
 /* Returns the value of the cookie, or undefined
    if the cookie is not present. */
 function read_cookie() {
-    var split, name, value;
+    var str, j;
     var cookies = document.cookie.split(";");
 
     for (i in cookies) {
-        split = cookies[i].split("=");
-        name = split[0];
-        value = split[1];
+        str = cookies[i];
 
-        while (name[0] === " ")
-            name = name.substr(1);
-        if (COOKIE_NAME === name)
-            return value;
+        while (str[0] === " ")
+            str = str.substr(1);
+
+        j = str.indexOf("=");
+        if (COOKIE_NAME === str.substr(0, j))
+            return str.substr(j + 1);
     }
     return undefined;
 }



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