Skip to content

Commit 6aea0de

Browse files
committed
Detect and clean up the buggy 2.2 configurations
(This should only be needed for profiles where 2.2 was the first version of HTTPS Everywhere ever installed).
1 parent 81296ae commit 6aea0de

File tree

2 files changed

+49
-8
lines changed

2 files changed

+49
-8
lines changed

src/chrome/content/code/HTTPSRules.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ const HTTPSRules = {
357357
this.scanRulefiles(rulefiles);
358358
rulefiles = RuleWriter.enumerate(RuleWriter.getRuleDir());
359359
this.scanRulefiles(rulefiles);
360+
this.checkForBuggyDefaults();
360361
var t,i;
361362
for (t in this.targets) {
362363
for (i = 0 ; i < this.targets[t].length ; i++) {
@@ -397,6 +398,53 @@ const HTTPSRules = {
397398
}
398399
},
399400

401+
checkForBuggyDefaults: function() {
402+
// The 2.2 release had a ruleset parsing bug which caused the match_rule
403+
// attribute to be misinterpreted as the default_off attribute. That was
404+
// a big problem iff 2.2 was the first version of HTTPS Everywhere
405+
// installed in a particular browser profile. If enough buggy rulesets
406+
// are on, conclude that this is such a profile, and reset to the correct
407+
// defaults. More here:
408+
//
409+
// https://mail1.eff.org/pipermail/https-everywhere/2012-August/001511.html
410+
//
411+
this.log(DBUG, "Checking for buggy configurations from version 2.2");
412+
// All of these were default_off in 2.2, and none of them had a
413+
// match_rule:
414+
var shouldBeOff = ["SchuelerVZ","Tcodevelopment.com","33Bits","BerliOS",
415+
"BuisnessInsider (broken)","Daft.ie","DVDFab",
416+
"YouMail (buggy)","StudiVZ (disabled)","Woot (broken)"];
417+
418+
var nonBuggy = 0;
419+
for (rulename in shouldBeOff) {
420+
// Some of these shouldBeOff rules may be removed in the future, so
421+
// tolerate their absence
422+
if (rulename in this.rulesetsByName) {
423+
if (!this.rulesetsByName[rulename].active)
424+
nonBuggy += 1;
425+
} else {
426+
this.log("INFO", "Couldn't check state of ruleset " + rulename);
427+
}
428+
}
429+
430+
// Heuristic: a user starting with a buggy config might have disabled up
431+
// to 2 of the 10 broken rulesets manually, but we will still conclude
432+
// that their config is broken and reset it
433+
if (nonBuggy <= 2) {
434+
this.log(WARN, "Detected a buggy-looking configuration, probably from HTTPS Everywhere 2.2. Resetting ruleset states to defaults");
435+
this.resetRulesetsToDefaults();
436+
}
437+
},
438+
439+
resetRulesetsToDefaults: function() {
440+
// Callable from within the prefs UI and also for cleaning up buggy
441+
// configurations...
442+
for (var i in this.rulesets) {
443+
if (this.rulesets[i].on_by_default) this.rulesets[i].enable();
444+
else this.rulesets[i].disable();
445+
}
446+
},
447+
400448
rewrittenURI: function(alist, input_uri) {
401449
// This function oversees the task of working out if a uri should be
402450
// rewritten, what it should be rewritten to, and recordkeeping of which

src/chrome/content/preferences.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,7 @@ function disable_all() {
2424

2525
// Reset all rules to their default state.
2626
function reset_defaults() {
27-
for (var i in rulesets) {
28-
if (rulesets[i].on_by_default) {
29-
rulesets[i].enable();
30-
} else {
31-
rulesets[i].disable();
32-
}
33-
}
34-
27+
https_everywhere.https_rules.resetRulesetsToDefaults()
3528
treeView.treebox.invalidate();
3629
}
3730

0 commit comments

Comments
 (0)