Work in progress on broken rule indication. · dholbert/https-everywhere@8ccfcca · GitHub
Skip to content

Commit 8ccfcca

Browse files
committed
Work in progress on broken rule indication.
1 parent 7ce42e3 commit 8ccfcca

6 files changed

Lines changed: 96 additions & 42 deletions

File tree

src/chrome/content/code/ApplicableList.js

Lines changed: 44 additions & 18 deletions

src/chrome/content/code/HTTPS.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@ const HTTPS = {
2929
httpsRewrite: null,
3030

3131
replaceChannel: function(applicable_list, channel) {
32-
var uri = HTTPSRules.rewrittenURI(applicable_list, channel.URI);
33-
if (!uri) {
32+
var blob = HTTPSRules.rewrittenURI(applicable_list, channel.URI);
33+
if (null == blob) {
3434
//HTTPS.log(INFO,
3535
// "Got replace channel with no applicable rules for URI "
3636
// + channel.URI.spec);
3737
return false;
3838
}
39+
var uri = blob.newuri;
40+
if (!uri) this.log(WARN, "OH NO BAD ARGH\nARGH");
3941

4042
var c2=channel.QueryInterface(CI.nsIHttpChannel);
4143
this.log(DBUG,"Redirection limit is " + c2.redirectionLimit);
@@ -46,7 +48,11 @@ const HTTPS = {
4648
if (c2.redirectionLimit < 10) {
4749
this.log(WARN, "Redirection loop trying to set HTTPS on:\n " +
4850
channel.URI.spec +"\n(falling back to HTTP)");
49-
https_everywhere_blacklist[channel.URI.spec] = true;
51+
if (!blob.applied_rule) {
52+
this.log(WARN,"DEATH\nDEATH\nDEATH\nDEATH");
53+
https_everywhere_blacklist[channel.URI.spec] = true;
54+
}
55+
https_everywhere_blacklist[channel.URI.spec] = blob.applied_rule;
5056
return false;
5157
}
5258
if (ChannelReplacement.supported) {
@@ -97,7 +103,7 @@ const HTTPS = {
97103
return null;
98104
}
99105
domWin = doc.defaultView;
100-
this.log(DBUG,"Coerced nsIDOMWin from Node: " + domWin);
106+
//this.log(DBUG,"Coerced nsIDOMWin from Node: " + domWin);
101107
} else {
102108
this.log(WARN, "Context for " + uri.spec +
103109
"is some bizarre unexpected thing: " + ctx);
@@ -116,8 +122,9 @@ const HTTPS = {
116122
// what rulesets might have applied to this page
117123
this.log(VERB, "Context is " + ctx);
118124
var alist = this.getApplicableListForContext(ctx, uri);
119-
var newuri = HTTPSRules.rewrittenURI(alist, uri);
120-
if (!newuri) return true; // no applicable rule
125+
var blob = HTTPSRules.rewrittenURI(alist, uri);
126+
if (null == blob) return true; // no applicable rule
127+
var newuri = blob.newuri;
121128

122129
try {
123130
if (this.rewriteInPlace(uri, newuri))

src/chrome/content/code/HTTPSRules.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,13 @@ const HTTPSRules = {
347347
rewrittenURI: function(alist, uri) {
348348
// This function oversees the task of working out if a uri should be
349349
// rewritten, what it should be rewritten to, and recordkeeping of which
350-
// applicable rulesets are and aren't active.
350+
// applicable rulesets are and aren't active. Previously this returned
351+
// the new uri if there was a rewrite. Now it returns a JS object with
352+
// a newuri attribute and an applied_rule attribute (or null if there's no
353+
// rewrite).
351354
var i = 0;
352-
var newuri = null
355+
var blob = {};
356+
blob.newuri = null;
353357
try {
354358
var rs = this.potentiallyApplicableRulesets(uri.host);
355359
} catch(e) {
@@ -364,11 +368,16 @@ const HTTPSRules = {
364368
alist.inactive_rule(rs[i]);
365369
continue;
366370
}
367-
newuri = rs[i].transformURI(uri);
368-
if (newuri) {
371+
blob.newuri = rs[i].transformURI(uri);
372+
if (blob.newuri) {
369373
// we rewrote the uri
370-
if (alist) alist.active_rule(rs[i]);
371-
return newuri;
374+
if (alist)
375+
if (blob.newuri.spec in https_everywhere_blacklist)
376+
alist.breaking_rule(rs[i])
377+
else
378+
alist.active_rule(rs[i]);
379+
blob.applied_rule = rs[i];
380+
return blob;
372381
}
373382
if (uri.scheme == "https" && alist) {
374383
// we didn't rewrite but the rule applies to this domain and the

src/chrome/skin/https-everywhere.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ toolbar[iconsize="small"] #https-everywhere-button {
1717
opacity: 0.5;
1818
font-weight: bold;
1919
}
20+
#https-everywhere-button menuitem.breaking-item label {
21+
color: #b99999;
22+
font-weight: bold;
23+
}
2024
#https-everywhere-button menuitem.inactive-item label {
2125
color: #999999;
2226
font-weight: bold;

src/chrome/skin/tick-red.png

459 Bytes
Loading

src/components/https-everywhere.js

Lines changed: 20 additions & 12 deletions

0 commit comments

Comments
 (0)