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

Unified Diff: lib/csp.js

Issue 29998582: Issue [TBD] - Update adblockpluscore dependency to [TBD] Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Created Feb. 5, 2019, 4:07 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 | « no previous file | lib/devtools.js » ('j') | lib/requestBlocker.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/csp.js
===================================================================
--- a/lib/csp.js
+++ b/lib/csp.js
@@ -15,73 +15,71 @@
* 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 {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 =>
{
let url = new URL(details.url);
let parentFrame = ext.getFrame(details.tabId, details.parentFrameId);
let hostname = extractHostFromFrame(parentFrame) || url.hostname;
- let thirdParty = isThirdParty(url, hostname);
- let cspMatch = defaultMatcher.matchesAny(details.url, typeMap.CSP, hostname,
- thirdParty, null, false);
+ let cspMatch = defaultMatcher.matchesAny(url, typeMap.CSP, hostname,
+ null, false);
if (cspMatch)
{
let page = new ext.Page({id: details.tabId, url: details.url});
let frame = ext.getFrame(details.tabId, details.frameId);
if (checkWhitelisted(page, frame))
return;
// To avoid an extra matchesAny for the common case we assumed no
// $genericblock filters applied when searching for a matching $csp filter.
// We must now pay the price by first checking for a $genericblock filter
// and if necessary that our $csp filter is specific.
let specificOnly = !!checkWhitelisted(page, frame, null,
typeMap.GENERICBLOCK);
if (specificOnly && !(cspMatch instanceof WhitelistFilter))
{
- cspMatch = defaultMatcher.matchesAny(details.url, typeMap.CSP, hostname,
- thirdParty, null, specificOnly);
+ cspMatch = defaultMatcher.matchesAny(url, typeMap.CSP, hostname,
+ null, specificOnly);
if (!cspMatch)
return;
}
if (cspMatch instanceof WhitelistFilter)
{
logRequest([details.tabId], {
url: details.url, type: "CSP", docDomain: hostname,
- thirdParty, specificOnly
+ specificOnly
}, cspMatch);
Sebastian Noack 2019/02/05 04:41:43 Nit: It seems this could be wrapped more readable
Manish Jethani 2019/02/05 05:16:19 Done.
filterNotifier.emit("filter.hitCount", cspMatch, 0, 0, [details.tabId]);
return;
}
- let {blocking} = defaultMatcher.search(details.url, typeMap.CSP, hostname,
- thirdParty, null, specificOnly,
+ let {blocking} = defaultMatcher.search(url, typeMap.CSP, hostname,
+ null, specificOnly,
"blocking");
for (cspMatch of blocking)
{
logRequest([details.tabId], {
url: details.url, type: "CSP", docDomain: hostname,
- thirdParty, specificOnly
+ specificOnly
}, cspMatch);
Sebastian Noack 2019/02/05 04:41:43 Nit: Same as above.
Manish Jethani 2019/02/05 05:16:19 Done.
filterNotifier.emit("filter.hitCount", cspMatch, 0, 0, [details.tabId]);
details.responseHeaders.push({
name: "Content-Security-Policy",
value: cspMatch.csp
});
}
« no previous file with comments | « no previous file | lib/devtools.js » ('j') | lib/requestBlocker.js » ('J')

Powered by Google App Engine
This is Rietveld