[or-cvs] [https-everywhere/master 3/4] Some optimisations of the cookie path

pde at torproject.org pde at torproject.org
Fri Nov 12 00:00:48 UTC 2010


Author: Peter Eckersley <pde at eff.org>
Date: Thu, 11 Nov 2010 15:45:24 -0800
Subject: Some optimisations of the cookie path
Commit: 039c616954a2dd82c509215f49709b771eba3151

---
 src/chrome/content/code/HTTPSRules.js |   24 ++++++++++++++----------
 1 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/src/chrome/content/code/HTTPSRules.js b/src/chrome/content/code/HTTPSRules.js
index 0d0818e..6a31a37 100644
--- a/src/chrome/content/code/HTTPSRules.js
+++ b/src/chrome/content/code/HTTPSRules.js
@@ -257,6 +257,7 @@ const HTTPSRules = {
   init: function() {
     try {
       this.rulesets = [];
+      this.crulesets = [];  // rulesets that contain cookierules
       var rulefiles = RuleWriter.enumerate(RuleWriter.getCustomRuleDir());
       this.scanRulefiles(rulefiles);
       rulefiles = RuleWriter.enumerate(RuleWriter.getRuleDir());
@@ -282,8 +283,11 @@ const HTTPSRules = {
       try {
         this.log(DBUG,"Loading ruleset file: "+rulefiles[i].path);
         r = RuleWriter.read(rulefiles[i]);
-        if (r != null)
+        if (r != null) {
           this.rulesets.push(r);
+          if (r.cookierules.length != 0) 
+            this.crulesets.push(r)
+        }
       } catch(e) {
         this.log(WARN, "Error in ruleset file: " + e);
       }
@@ -312,17 +316,17 @@ const HTTPSRules = {
   should_secure_cookie: function(c) {
     // Check to see if the Cookie object c meets any of our cookierule citeria 
     // for being marked as secure
-    this.log(DBUG, "Testing cookie:");
-    this.log(DBUG, "  name: " + c.name);
-    this.log(DBUG, "  host: " + c.host);
-    this.log(DBUG, "  domain: " + c.domain);
-    this.log(DBUG, "  rawhost: " + c.rawHost);
+    //this.log(DBUG, "Testing cookie:");
+    //this.log(DBUG, "  name: " + c.name);
+    //this.log(DBUG, "  host: " + c.host);
+    //this.log(DBUG, "  domain: " + c.domain);
+    //this.log(DBUG, "  rawhost: " + c.rawHost);
     var i,j;
     // XXX lots of optimisation could happen here
-    for (i = 0; i < this.rulesets.length; ++i) 
-      if (this.rulesets[i].active) 
-        for (j = 0; j < this.rulesets[i].cookierules.length; j++) {
-          var cr = this.rulesets[i].cookierules[j];
+    for (i = 0; i < this.crulesets.length; ++i) 
+      if (this.crulesets[i].active) 
+        for (j = 0; j < this.crulesets[i].cookierules.length; j++) {
+          var cr = this.crulesets[i].cookierules[j];
           if (cr.host_c.test(c.host) && cr.name_c.test(c.name)) 
             return true;
         }
-- 
1.7.1




More information about the tor-commits mailing list