diff options
author | hackademix | 2018-08-21 23:51:59 +0200 |
---|---|---|
committer | hackademix | 2018-08-21 23:51:59 +0200 |
commit | 91334fe94477fdbcb85fcf93d87e3c73294da106 (patch) | |
tree | 34224a6b802e7aeceb420112ac257535800bdcbd /src | |
parent | e742e5d80102c01174d5d26d7b7c209fbd02cc9a (diff) | |
download | noscript-91334fe94477fdbcb85fcf93d87e3c73294da106.tar.gz noscript-91334fe94477fdbcb85fcf93d87e3c73294da106.tar.xz noscript-91334fe94477fdbcb85fcf93d87e3c73294da106.zip |
Fixed inconstitencies in ChildPolicies content script URL matching.
Diffstat (limited to 'src')
-rw-r--r-- | src/bg/ChildPolicies.js | 3 | ||||
-rw-r--r-- | src/common/Policy.js | 21 |
2 files changed, 22 insertions, 2 deletions
diff --git a/src/bg/ChildPolicies.js b/src/bg/ChildPolicies.js index 5b1b209..32abafe 100644 --- a/src/bg/ChildPolicies.js +++ b/src/bg/ChildPolicies.js @@ -111,11 +111,12 @@ // compute exclusions let permsMapEntries = [...permsMap]; let excludeMap = new Map(); + for (let [perms, keys] of permsMapEntries) { excludeMap.set(perms, siteKeys2MatchPatterns(flatten( permsMapEntries.filter(([other]) => other !== perms) .map(([otherPerms, otherKeys]) => otherKeys)) - .filter(k => k && k.includes("/")) + .filter(k => k && k.includes("/") && keys.some(by => Sites.isImplied(k, by))) )); } diff --git a/src/common/Policy.js b/src/common/Policy.js index 6adc2ae..24c3179 100644 --- a/src/common/Policy.js +++ b/src/common/Policy.js @@ -20,7 +20,26 @@ var {Permissions, Policy, Sites} = (() => { static isValid(site) { return /^(?:https?:(?:\/\/)?)?([\w\u0100-\uf000][\w\u0100-\uf000.-]*)?[\w\u0100-\uf000](?::\d+)?$/.test(site); } - + + + static originImplies(originKey, site) { + return originKey === site || site.startsWith(`${originKey}/`); + } + static domainImplies(domainKey, site, protocol = null) { + if (!protocol) { + return (Sites.isSecureDomainKey(domainKey)) + ? Sites.domainImplies(Sites.toggleSecureDomainKey(domainKey, false), site, "https") + : ["http", "https"].some(protocol => Sites.domainImplies(domainKey, site, protocol)); + } + return Sites.originImplies(`${protocol}://${domainKey}`, site); + } + + static isImplied(site, byKey) { + return byKey.includes("://") + ? Sites.originImplies(byKey, site) + : Sites.domainImplies(byKey, site); + } + static parse(site) { let url, siteKey = ""; if (site instanceof URL) { |