[or-cvs] [https-everywhere/master 1/2] <ruleset default_off="yes"> is now possible

pde at torproject.org pde at torproject.org
Wed Oct 13 19:44:11 UTC 2010


Author: Peter Eckersley <pde at eff.org>
Date: Wed, 13 Oct 2010 12:40:09 -0700
Subject: <ruleset default_off="yes"> is now possible
Commit: ef3fcb8288a8bc0f7c29400ffd8af6b13db93a1b

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

diff --git a/src/chrome/content/code/HTTPSRules.js b/src/chrome/content/code/HTTPSRules.js
index 27c9eea..54c0426 100644
--- a/src/chrome/content/code/HTTPSRules.js
+++ b/src/chrome/content/code/HTTPSRules.js
@@ -9,7 +9,8 @@ function Exclusion(pattern) {
   this.pattern_c = new RegExp(pattern);
 }
 
-function RuleSet(name, match_rule) {
+function RuleSet(name, match_rule, default_off) {
+  var on_by_default = true;
   this.name = name;
   this.ruleset_match = match_rule;
   if (match_rule) {
@@ -17,6 +18,12 @@ function RuleSet(name, match_rule) {
   } else {
     this.ruleset_match_c = null;
   }
+  if (default_off) {
+    // Perhaps problematically, this currently ignores the actual content of
+    // the default_off XML attribute.  Ideally we'd like this attribute to be
+    // "valueless"
+    on_by_default = false;
+  }
   this.rules = [];
   this.exclusions = [];
   var prefs = HTTPSEverywhere.instance.get_prefs();
@@ -27,7 +34,7 @@ function RuleSet(name, match_rule) {
     // if not, create it
     this.log(DBUG, "Creating new pref " + name);
     this.active = true;
-    prefs.setBoolPref(name, true);
+    prefs.setBoolPref(name, on_by_default);
   }
 }
 
@@ -197,11 +204,11 @@ const RuleWriter = {
       return null;
     }
 
-    if (xmlrules. at match_rule.length() > 0) {
-      var ret = new RuleSet(xmlrules. at name, xmlrules. at match_rule);
-    } else {
-      var ret = new RuleSet(xmlrules. at name, null);
-    }
+    var match_rl = null;
+    var dflt_off = null;
+    if (xmlrules. at match_rule.length() > 0) match_rl = xmlrules. at match_rule;
+    if (xmlrules. at default_off.length() > 0) dflt_off = xmlrules. at default_off;
+    var ret = new RuleSet(xmlrules. at name, match_rl, dflt_off);
 
     for (var i = 0; i < xmlrules.exclusion.length(); i++) {
       var exclusion = new Exclusion(xmlrules.exclusion[i]. at pattern);
-- 
1.7.1




More information about the tor-commits mailing list