Skip to content

Commit 5ef57c3

Browse files
Chan Chak Shingzoracon
authored andcommitted
Avoid redundant statement branching in safeToSecureCookie() (EFForg#17736)
* Avoid redundant statement branching in safeToSecureCookie() * Use ES6 let and avoid unnecessary assignments * Reverse using ES6 let to simplify the changes * Update rules.js
1 parent 7bc1255 commit 5ef57c3

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

chromium/background-scripts/rules.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -626,11 +626,10 @@ RuleSets.prototype = {
626626
}
627627

628628
var potentiallyApplicable = this.potentiallyApplicableRulesets(hostname);
629-
for (let ruleset of potentiallyApplicable) {
629+
for (const ruleset of potentiallyApplicable) {
630630
if (ruleset.cookierules !== null && ruleset.active) {
631-
for (let cookierules of ruleset.cookierules) {
632-
var cr = cookierules;
633-
if (cr.host_c.test(cookie.domain) && cr.name_c.test(cookie.name)) {
631+
for (const cookierule of ruleset.cookierules) {
632+
if (cookierule.host_c.test(cookie.domain) && cookierule.name_c.test(cookie.name)) {
634633
return ruleset;
635634
}
636635
}
@@ -683,10 +682,7 @@ RuleSets.prototype = {
683682
util.log(util.INFO, "Testing securecookie applicability with " + test_uri);
684683
var potentiallyApplicable = this.potentiallyApplicableRulesets(domain);
685684
for (let ruleset of potentiallyApplicable) {
686-
if (!ruleset.active) {
687-
continue;
688-
}
689-
if (ruleset.apply(test_uri)) {
685+
if (ruleset.active && ruleset.apply(test_uri)) {
690686
util.log(util.INFO, "Cookie domain could be secured.");
691687
this.cookieHostCache.set(domain, true);
692688
return true;

0 commit comments

Comments
 (0)