| 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 |
| }); |
| } |