Skip to content

Commit 2b506b0

Browse files
committed
Remove match_rule and f attributes.
1 parent 2f85fed commit 2b506b0

File tree

6 files changed

+8
-54
lines changed

6 files changed

+8
-54
lines changed

chromium/rules.js

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,12 @@ function CookieRule(host, cookiename) {
4040
/**
4141
*A collection of rules
4242
* @param set_name The name of this set
43-
* @param match_rule Quick test match rule
4443
* @param default_state activity state
4544
* @param note Note will be displayed in popup
4645
* @constructor
4746
*/
48-
function RuleSet(set_name, match_rule, default_state, note) {
47+
function RuleSet(set_name, default_state, note) {
4948
this.name = set_name;
50-
if (match_rule)
51-
this.ruleset_match_c = new RegExp(match_rule);
52-
else
53-
this.ruleset_match_c = null;
5449
this.rules = [];
5550
this.exclusions = [];
5651
this.targets = [];
@@ -75,11 +70,6 @@ RuleSet.prototype = {
7570
return null;
7671
}
7772
}
78-
// If a ruleset has a match_rule and it fails, go no further
79-
if (this.ruleset_match_c && !this.ruleset_match_c.test(urispec)) {
80-
log(VERB, "ruleset_match_c excluded " + urispec);
81-
return null;
82-
}
8373

8474
// Okay, now find the first rule that triggers
8575
for(var i = 0; i < this.rules.length; ++i) {
@@ -89,12 +79,6 @@ RuleSet.prototype = {
8979
return returl;
9080
}
9181
}
92-
if (this.ruleset_match_c) {
93-
// This is not an error, because we do not insist the matchrule
94-
// precisely describes to target space of URLs ot redirected
95-
log(DBUG,"Ruleset "+this.name
96-
+" had an applicable match-rule but no matching rules");
97-
}
9882
return null;
9983
}
10084

@@ -162,7 +146,7 @@ RuleSets.prototype = {
162146
*/
163147
addUserRule : function(params) {
164148
log(INFO, 'adding new user rule for ' + JSON.stringify(params));
165-
var new_rule_set = new RuleSet(params.host, null, true, "user rule");
149+
var new_rule_set = new RuleSet(params.host, true, "user rule");
166150
var new_rule = new Rule(params.urlMatcher, params.redirectTo);
167151
new_rule_set.rules.push(new_rule);
168152
if (!(params.host in this.targets)) {
@@ -202,7 +186,6 @@ RuleSets.prototype = {
202186
}
203187

204188
var rule_set = new RuleSet(ruletag.getAttribute("name"),
205-
ruletag.getAttribute("match_rule"),
206189
default_state,
207190
note.trim());
208191

src/chrome/content/code/HTTPSRules.js

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,13 @@ function CookieRule(host, cookiename) {
1919
//this.name_c = new RegExp(cookiename);
2020
}
2121

22-
function RuleSet(id, name, xmlName, match_rule, default_off, platform) {
23-
if(xmlName == "WordPress.xml" || xmlName == "Github.xml") {
24-
this.log(NOTE, "RuleSet( name="+name+", xmlName="+xmlName+", match_rule="+match_rule+", default_off="+default_off+", platform="+platform+" )");
25-
}
26-
22+
function RuleSet(id, name, default_off, platform) {
2723
this.id=id;
2824
this.on_by_default = true;
2925
this.compiled = false;
3026
this.name = name;
31-
this.xmlName = xmlName;
3227
this.notes = "";
3328

34-
if (match_rule) this.ruleset_match_c = new RegExp(match_rule);
35-
else this.ruleset_match_c = null;
3629
if (default_off) {
3730
// Perhaps problematically, this currently ignores the actual content of
3831
// the default_off XML attribute. Ideally we'd like this attribute to be
@@ -93,12 +86,7 @@ RuleSet.prototype = {
9386
var i;
9487
var returl = null;
9588
this.ensureCompiled();
96-
// If a rulset has a match_rule and it fails, go no further
97-
if (this.ruleset_match_c && !this.ruleset_match_c.test(urispec)) {
98-
this.log(VERB, "ruleset_match_c excluded " + urispec);
99-
return null;
100-
}
101-
// Even so, if we're covered by an exclusion, go home
89+
// If we're covered by an exclusion, go home
10290
for (i = 0; i < this.exclusions.length; ++i) {
10391
if (this.exclusions[i].pattern_c.test(urispec)) {
10492
this.log(DBUG,"excluded uri " + urispec);
@@ -111,7 +99,7 @@ RuleSet.prototype = {
11199
returl = urispec.replace(this.rules[i].from_c, this.rules[i].to);
112100
if (returl != urispec) {
113101
// we rewrote the uri
114-
this.log(DBUG, "Rewrote " + urispec + " -> " + returl + " using " + this.xmlName + ": " + this.rules[i].from_c + " -> " + this.rules[i].to);
102+
this.log(DBUG, "Rewrote " + urispec + " -> " + returl + " using " + this.name + ": " + this.rules[i].from_c + " -> " + this.rules[i].to);
115103
return returl;
116104
}
117105
}
@@ -139,13 +127,10 @@ RuleSet.prototype = {
139127
var urispec = uri.spec;
140128

141129
this.ensureCompiled();
142-
143-
if (this.ruleset_match_c && !this.ruleset_match_c.test(urispec))
144-
return false;
145-
130+
146131
for (var i = 0; i < this.exclusions.length; ++i)
147132
if (this.exclusions[i].pattern_c.test(urispec)) return false;
148-
133+
149134
for (var i = 0; i < this.rules.length; ++i)
150135
if (this.rules[i].from_c.test(urispec)) return true;
151136
return false;
@@ -309,10 +294,9 @@ const RuleWriter = {
309294

310295
this.log(DBUG, "Parsing " + xmlruleset.getAttribute("name"));
311296

312-
var match_rl = xmlruleset.getAttribute("match_rule");
313297
var dflt_off = xmlruleset.getAttribute("default_off");
314298
var platform = xmlruleset.getAttribute("platform");
315-
var rs = new RuleSet(ruleset_id, xmlruleset.getAttribute("name"), xmlruleset.getAttribute("f"), match_rl, dflt_off, platform);
299+
var rs = new RuleSet(ruleset_id, xmlruleset.getAttribute("name"), dflt_off, platform);
316300

317301
// see if this ruleset has the same name as an existing ruleset;
318302
// if so, this ruleset is ignored; DON'T add or return it.

utils/make-sqlite.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,6 @@
8181
# pointing into the ruleset table.
8282
etree.strip_tags(tree, 'target')
8383

84-
# Store the filename in the `f' attribute so "view source XML" for rules in
85-
# FF version can find it.
86-
xpath_ruleset(tree)[0].attrib["f"] = os.path.basename(fi).decode(encoding="UTF-8")
87-
8884
c.execute('''INSERT INTO rulesets (contents) VALUES(?)''', (etree.tostring(tree),))
8985
ruleset_id = c.lastrowid
9086
for target in targets:

utils/merge-rulesets.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,10 @@ def clean_up(rulefile):
7272
# Chromium
7373
library.write('<rulesetlibrary>')
7474

75-
# Include the filename.xml as the "f" attribute
7675
print("Removing whitespaces and comments...")
7776

7877
for rfile in sorted(xml_ruleset_files):
7978
ruleset = open(rfile).read()
80-
fn = os.path.basename(rfile)
81-
ruleset = ruleset.replace("<ruleset", '<ruleset f="%s"' % fn, 1)
8279
library.write(clean_up(ruleset))
8380
library.write("</rulesetlibrary>\n")
8481
library.close()

utils/relaxng.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
<element xmlns="http://relaxng.org/ns/structure/1.0" name="ruleset" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
22
<attribute name="name" />
33

4-
<optional>
5-
<attribute name="match_rule" />
6-
</optional>
7-
84
<optional>
95
<attribute name="default_off" />
106
</optional>

utils/simple.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ def simple(f):
1818
return all([
1919
# ruleset must not be default_off
2020
"default_off" not in tree.xpath("/ruleset")[0].attrib,
21-
# ruleset must not contain a match_rule
22-
"match_rule" not in tree.xpath("/ruleset")[0].attrib,
2321
# XXX: maybe also check for platform="mixedcontent" here
2422
# ruleset must not apply any securecookie patterns
2523
not tree.xpath("/ruleset/securecookie"),

0 commit comments

Comments
 (0)