Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/csp.js

Issue 29991594: Issue 7243 - Update adblockpluscore dependency to hg:e26e122e0702 (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Compare CSP filters by text Created Jan. 31, 2019, 2:49 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dependencies ('k') | lib/devtools.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/csp.js
===================================================================
--- a/lib/csp.js
+++ b/lib/csp.js
@@ -15,17 +15,18 @@
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
*/
"use strict";
const {defaultMatcher} = require("../adblockpluscore/lib/matcher");
const {RegExpFilter, WhitelistFilter} =
require("../adblockpluscore/lib/filterClasses");
-const {extractHostFromFrame, isThirdParty} = require("./url");
+const {isThirdParty} = require("../adblockpluscore/lib/domain");
+const {extractHostFromFrame} = require("./url");
const {checkWhitelisted} = require("./whitelisting");
const {filterNotifier} = require("filterNotifier");
const {logRequest} = require("./hitLogger");
const {typeMap} = RegExpFilter;
browser.webRequest.onHeadersReceived.addListener(details =>
{
@@ -53,28 +54,41 @@
if (specificOnly && !(cspMatch instanceof WhitelistFilter))
{
cspMatch = defaultMatcher.matchesAny(details.url, typeMap.CSP, hostname,
thirdParty, null, specificOnly);
if (!cspMatch)
return;
}
- logRequest([details.tabId], {
- url: details.url, type: "CSP", docDomain: hostname,
- thirdParty, specificOnly
- }, cspMatch);
- filterNotifier.emit("filter.hitCount", cspMatch, 0, 0, [details.tabId]);
+ if (cspMatch instanceof WhitelistFilter)
+ {
+ logRequest([details.tabId], {
+ url: details.url, type: "CSP", docDomain: hostname,
+ thirdParty, specificOnly
+ }, cspMatch);
+ filterNotifier.emit("filter.hitCount", cspMatch, 0, 0, [details.tabId]);
+ return;
+ }
- if (cspMatch instanceof WhitelistFilter)
- return;
+ let {blocking} = defaultMatcher.search(details.url, typeMap.CSP, hostname,
+ thirdParty, null, specificOnly,
+ "blocking");
+ for (cspMatch of blocking)
+ {
+ logRequest([details.tabId], {
+ url: details.url, type: "CSP", docDomain: hostname,
+ thirdParty, specificOnly
+ }, cspMatch);
+ filterNotifier.emit("filter.hitCount", cspMatch, 0, 0, [details.tabId]);
- details.responseHeaders.push({
- name: "Content-Security-Policy",
- value: cspMatch.csp
- });
+ details.responseHeaders.push({
+ name: "Content-Security-Policy",
+ value: cspMatch.csp
+ });
+ }
return {responseHeaders: details.responseHeaders};
}
}, {
urls: ["http://*/*", "https://*/*"],
types: ["main_frame", "sub_frame"]
}, ["blocking", "responseHeaders"]);
« no previous file with comments | « dependencies ('k') | lib/devtools.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld