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

[tor-commits] [flashproxy/master] Check for cookie by iterating through cookie names.



commit a0a9f4caefa8d7a1189ab9984bcd1d62b25e3c3a
Author: Alexandre Allaire <alexandre.allaire@xxxxxxxxxxxxxx>
Date:   Thu Dec 6 14:37:08 2012 -0500

    Check for cookie by iterating through cookie names.
    
    Check is currently done by searching entire document.cookie
    string for the cookie name. If an unrelated cookie has
    this name in its value, the cookie is incorrectly considered
    to be present.
---
 proxy/options.js |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/proxy/options.js b/proxy/options.js
index 350b472..c10b189 100644
--- a/proxy/options.js
+++ b/proxy/options.js
@@ -17,7 +17,22 @@ window.addEventListener("load", function () {
             return true;
         } else if (navigator.cookieEnabled === undefined) {
             document.cookie = "test";
-            if (document.cookie.indexOf("test") !== -1)
+            if (cookie_present("test"))
+                return true;
+        }
+        return false;
+    }
+
+    /* Checks for a cookie with name cookie */
+    function cookie_present(cookie) {
+        var cookies = document.cookie.split(";");
+
+        for (i in cookies) {
+            var name = cookies[i].split("=")[0];
+
+            while (name[0] === " ")
+                name = name.substr(1);
+            if (cookie === name)
                 return true;
         }
         return false;
@@ -28,7 +43,7 @@ window.addEventListener("load", function () {
         var setting = document.getElementById("setting");
         var prefix = "<p>Your current setting is: ";
 
-        if (document.cookie.indexOf(COOKIE_NAME) !== -1) {
+        if (cookie_present(COOKIE_NAME)) {
             setting.innerHTML = prefix + "use my browser as a proxy. " +
                                          "Click no below to change your setting.</p>";
         } else {



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