Skip to content

Commit 7557f83

Browse files
committed
Tentatively, try to consider <securecookie> for applicable rules lists
1 parent ac808dd commit 7557f83

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

src/chrome/content/code/HTTPS.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ const HTTPS = {
9797
return null;
9898
}
9999
domWin = doc.defaultView;
100-
this.log(WARN,"Coerced nsIDOMWin from Node: " + domWin);
100+
this.log(DBUG,"Coerced nsIDOMWin from Node: " + domWin);
101101
} else {
102102
this.log(WARN, "Context for " + uri.spec +
103103
"is some bizarre unexpected thing: " + ctx);
@@ -183,7 +183,10 @@ const HTTPS = {
183183
this.log(WARN,"No URI inside request " +req);
184184
return;
185185
}
186-
//this.log(VERB, "Cookie hunting in " + uri.spec);
186+
this.log(DBUG, "Cookie hunting in " + uri.spec);
187+
var alist = HTTPSEverywhere.instance.getApplicableListForChannel(req);
188+
if (!alist)
189+
this.log(INFO, "No alist for cookies for "+(req.URI) ? req.URI.spec : "???");
187190

188191
if (uri.schemeIs("https")) {
189192
var host = uri.host;
@@ -198,7 +201,7 @@ const HTTPS = {
198201
for each (var cs in cookies.split("\n")) {
199202
this.log(DBUG, "Examining cookie: ");
200203
c = new Cookie(cs, host);
201-
if (!c.secure && HTTPSRules.shouldSecureCookie(c)) {
204+
if (!c.secure && HTTPSRules.shouldSecureCookie(alist, c)) {
202205
this.log(INFO, "Securing cookie: " + c.domain + " " + c.name);
203206
c.secure = true;
204207
req.setResponseHeader("Set-Cookie", c.source + ";Secure", true);

src/chrome/content/code/HTTPSRules.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ RuleSet.prototype = {
9595

9696
for (i = 0; i < this.rules.length; ++i)
9797
if (this.rules[i].from_c.test(urispec)) return true;
98-
this.log(DBUG, "No, we fell through");
9998
return false;
10099
},
101100

@@ -402,12 +401,12 @@ const HTTPSRules = {
402401
return results;
403402
},
404403

405-
shouldSecureCookie: function(c) {
404+
shouldSecureCookie: function(applicable_list, c) {
406405
// Check to see if the Cookie object c meets any of our cookierule citeria
407406
// for being marked as secure
408-
//this.log(DBUG, "Testing cookie:");
409-
//this.log(DBUG, " name: " + c.name);
410-
//this.log(DBUG, " host: " + c.host);
407+
this.log(DBUG, "Testing cookie:");
408+
this.log(DBUG, " name: " + c.name);
409+
this.log(DBUG, " host: " + c.host);
411410
//this.log(DBUG, " domain: " + c.domain);
412411
//this.log(DBUG, " rawhost: " + c.rawHost);
413412
var i,j;
@@ -417,9 +416,16 @@ const HTTPSRules = {
417416
if (ruleset.active)
418417
for (j = 0; j < ruleset.cookierules.length; j++) {
419418
var cr = ruleset.cookierules[j];
420-
if (cr.host_c.test(c.host) && cr.name_c.test(c.name))
419+
if (cr.host_c.test(c.host) && cr.name_c.test(c.name)) {
420+
if (applicable_list) applicable_list.active_rule(ruleset);
421+
this.log(INFO,"Active cookie rule " + ruleset.name);
421422
return true;
423+
}
422424
}
425+
else if (ruleset.cookierules.length > 0) {
426+
applicable_list.inactive_rule(ruleset);
427+
this.log(INFO,"Inactive cookie rule " + ruleset.name);
428+
}
423429
}
424430
return false;
425431
}

src/components/https-everywhere.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,12 @@ HTTPSEverywhere.prototype = {
231231
// content is embedded / requested by JavaScript.
232232
onLocationChange: function(wp, req, uri) {
233233
if (wp instanceof CI.nsIWebProgress) {
234-
this.log(DBUG,"(Probably) Making new alist in onLocationChange");
234+
// XXX this should not work like this, and it possibly shouldn't exist
235+
// at all
236+
//this.log(DBUG,"(Probably) Making new alist in onLocationChange");
235237
if (!this.getApplicableListForDOMWin(wp.DOMWindow, "onLocChange"))
236238
this.log(WARN,"Something went wrong in onLocationChange");
237-
this.log(DBUG,"ok");
239+
//this.log(DBUG,"ok");
238240
} else {
239241
this.log(WARN,"onLocationChange: no nsIWebProgress");
240242
}

0 commit comments

Comments
 (0)