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

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



Author: Peter Eckersley <pde@xxxxxxx>
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.@xxxxxxxxxxxxxxxxx() > 0) {
-      var ret = new RuleSet(xmlrules.@name, xmlrules.@match_rule);
-    } else {
-      var ret = new RuleSet(xmlrules.@name, null);
-    }
+    var match_rl = null;
+    var dflt_off = null;
+    if (xmlrules.@xxxxxxxxxxxxxxxxx() > 0) match_rl = xmlrules.@match_rule;
+    if (xmlrules.@xxxxxxxxxxxxxxxxxx() > 0) dflt_off = xmlrules.@default_off;
+    var ret = new RuleSet(xmlrules.@name, match_rl, dflt_off);
 
     for (var i = 0; i < xmlrules.exclusion.length(); i++) {
       var exclusion = new Exclusion(xmlrules.exclusion[i].@pattern);
-- 
1.7.1