Skip to content

Commit d287299

Browse files
committed
Also remove wouldMatch.
This eliminates "moot" as a special category, and treats all rulesets that have a matching target host but are disabled as "inactive" in the applicable rules list, allowing us to eliminate a chunk of regex work in wouldMatch.
1 parent 2b506b0 commit d287299

File tree

3 files changed

+15
-86
lines changed

3 files changed

+15
-86
lines changed

src/chrome/content/code/ApplicableList.js

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ function ApplicableList(logger, uri) {
1717
this.active = {};
1818
this.breaking = {}; // rulesets with redirection loops
1919
this.inactive = {};
20-
this.moot={}; // rulesets that might be applicable but uris are already https
21-
this.all={}; // active + breaking + inactive + moot
20+
this.all={}; // active + breaking + inactive
2221
serial_number += 1;
2322
this.serial = serial_number;
2423
this.log(DBUG,"Alist serial #" + this.serial + " for " + this.home);
@@ -32,7 +31,6 @@ ApplicableList.prototype = {
3231
this.active = {};
3332
this.breaking = {};
3433
this.inactive = {};
35-
this.moot={};
3634
this.all={};
3735
},
3836

@@ -58,12 +56,6 @@ ApplicableList.prototype = {
5856
this.all[ruleset.name] = ruleset;
5957
},
6058

61-
moot_rule: function(ruleset) {
62-
this.log(INFO,"moot rule " + ruleset.name +" in "+ this.home + " serial " + this.serial);
63-
this.moot[ruleset.name] = ruleset;
64-
this.all[ruleset.name] = ruleset;
65-
},
66-
6759
dom_handler: function(operation,key,data,src,dst) {
6860
// See https://developer.mozilla.org/En/DOM/UserDataHandler
6961
if (src && dst)
@@ -182,19 +174,13 @@ ApplicableList.prototype = {
182174
this.add_command(this.breaking[x]);
183175
for(var x in this.active)
184176
this.add_command(this.active[x]);
185-
for(var x in this.moot)
186-
this.add_command(this.moot[x]);
187177
for(var x in this.inactive)
188178
this.add_command(this.inactive[x]);
189179

190180
if(https_everywhere.prefs.getBoolPref("globalEnabled")){
191181
// add all the menu items
192182
for (var x in this.inactive)
193183
this.add_menuitem(this.inactive[x], 'inactive');
194-
// rules that are active for some uris are not really moot
195-
for (var x in this.moot)
196-
if (!(x in this.active))
197-
this.add_menuitem(this.moot[x], 'moot');
198184
// break once break everywhere
199185
for (var x in this.active)
200186
if (!(x in this.breaking))
@@ -220,9 +206,8 @@ ApplicableList.prototype = {
220206
this.commandset.appendChild(command);
221207
},
222208

223-
// add a menu item for a rule -- type is "active", "inactive", "moot",
209+
// add a menu item for a rule -- type is "active", "inactive"
224210
// or "breaking"
225-
226211
add_menuitem: function(rule, type) {
227212
// create the menuitem
228213
var item = this.document.createElement('menuitem');
@@ -233,37 +218,20 @@ ApplicableList.prototype = {
233218

234219
// we can get confused if rulesets have their state changed after the
235220
// ApplicableList was constructed
236-
if (!rule.active && (type == 'active' || type == 'moot'))
221+
if (!rule.active && (type == 'active'))
237222
type = 'inactive';
238223
if (rule.active && type == 'inactive')
239-
type = 'moot';
240-
224+
type = 'active';
225+
241226
// set the icon
242227
var image_src;
243228
if (type == 'active') image_src = 'tick.png';
244229
else if (type == 'inactive') image_src = 'cross.png';
245-
else if (type == 'moot') image_src = 'tick-moot.png';
246230
else if (type == 'breaking') image_src = 'loop.png';
247231
item.setAttribute('image', 'chrome://https-everywhere/skin/'+image_src);
248232

249233
// all done
250234
this.prepend_child(item);
251-
},
252-
253-
show_applicable: function() {
254-
this.log(WARN, "Applicable list number " + this.serial);
255-
for (var x in this.active)
256-
this.log(WARN,"Active: " + this.active[x].name);
257-
258-
for (var x in this.breaking)
259-
this.log(WARN,"Breaking: " + this.breaking[x].name);
260-
261-
for (x in this.inactive)
262-
this.log(WARN,"Inactive: " + this.inactive[x].name);
263-
264-
for (x in this.moot)
265-
this.log(WARN,"Moot: " + this.moot[x].name);
266-
267235
}
268236
};
269237

src/chrome/content/code/HTTPSRules.js

Lines changed: 10 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -109,32 +109,6 @@ RuleSet.prototype = {
109109
log: function(level, msg) {
110110
https_everywhereLog(level, msg);
111111
},
112-
113-
wouldMatch: function(hypothetical_uri, alist) {
114-
// return true if this ruleset would match the uri, assuming it were http
115-
// used for judging moot / inactive rulesets
116-
// alist is optional
117-
118-
// if the ruleset is already somewhere in this applicable list, we don't
119-
// care about hypothetical wouldMatch questions
120-
if (alist && (this.name in alist.all)) return false;
121-
122-
this.log(DBUG,"Would " +this.name + " match " +hypothetical_uri.spec +
123-
"? serial " + (alist && alist.serial));
124-
125-
var uri = hypothetical_uri.clone();
126-
if (uri.scheme == "https") uri.scheme = "http";
127-
var urispec = uri.spec;
128-
129-
this.ensureCompiled();
130-
131-
for (var i = 0; i < this.exclusions.length; ++i)
132-
if (this.exclusions[i].pattern_c.test(urispec)) return false;
133-
134-
for (var i = 0; i < this.rules.length; ++i)
135-
if (this.rules[i].from_c.test(urispec)) return true;
136-
return false;
137-
},
138112

139113
transformURI: function(uri) {
140114
// If no rule applies, return null; if a rule would have applied but was
@@ -482,31 +456,26 @@ const HTTPSRules = {
482456
}
483457

484458
// ponder each potentially applicable ruleset, working out if it applies
485-
// and recording it as active/inactive/moot/breaking in the applicable list
459+
// and recording it as active/inactive/breaking in the applicable list
486460
for (i = 0; i < rs.length; ++i) {
487461
if (!rs[i].active) {
488-
if (alist && rs[i].wouldMatch(uri, alist))
489-
alist.inactive_rule(rs[i]);
490-
continue;
491-
}
462+
alist.inactive_rule(rs[i]);
463+
}
492464
blob.newuri = rs[i].transformURI(uri);
493465
if (blob.newuri) {
494466
if (alist) {
495-
if (uri.spec in https_everywhere_blacklist)
467+
if (uri.spec in https_everywhere_blacklist) {
496468
alist.breaking_rule(rs[i]);
497-
else
469+
} else {
498470
alist.active_rule(rs[i]);
499-
}
500-
if (userpass_present) blob.newuri.userPass = input_uri.userPass;
471+
}
472+
}
473+
if (userpass_present) {
474+
blob.newuri.userPass = input_uri.userPass;
475+
}
501476
blob.applied_ruleset = rs[i];
502477
return blob;
503478
}
504-
if (uri.scheme == "https" && alist) {
505-
// we didn't rewrite but the rule applies to this domain and the
506-
// requests are going over https
507-
if (rs[i].wouldMatch(uri, alist)) alist.moot_rule(rs[i]);
508-
continue;
509-
}
510479
}
511480
return null;
512481
},
@@ -693,9 +662,6 @@ const HTTPSRules = {
693662
return true;
694663
}
695664
}
696-
if (ruleset.cookierules.length > 0 && applicable_list) {
697-
applicable_list.moot_rule(ruleset);
698-
}
699665
} else if (ruleset.cookierules.length > 0) {
700666
if (applicable_list) {
701667
applicable_list.inactive_rule(ruleset);

src/chrome/content/toolbar_button.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,6 @@ httpsEverywhere.toolbarButton = {
198198
++counter;
199199
}
200200
}
201-
for (var x in alist.moot) {
202-
if (!(x in alist.active)) {
203-
++counter;
204-
}
205-
}
206201

207202
toolbarbutton.setAttribute('rulesetsApplied', counter);
208203
HTTPSEverywhere.log(INFO, 'Setting icon counter to: ' + counter);

0 commit comments

Comments
 (0)