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

Side by Side Diff: lib/csp.js

Issue 29713631: Issue 5760 - Use relative require paths (Closed)
Patch Set: Address PS3 comment Created April 3, 2018, 6:03 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 "use strict"; 18 "use strict";
19 19
20 // The webRequest API doesn't support WebSocket connection blocking in Microsoft 20 // The webRequest API doesn't support WebSocket connection blocking in Microsoft
kzar 2018/04/05 11:14:56 Looks like this needs rebasing (on top of the next
Jon Sonesen 2018/04/05 23:01:20 Acknowledged.
21 // Edge and versions of Chrome before 58. Therefore for those we inject CSP 21 // Edge and versions of Chrome before 58. Therefore for those we inject CSP
22 // headers below as a workaround. See https://crbug.com/129353 and 22 // headers below as a workaround. See https://crbug.com/129353 and
23 // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10297376 / 23 // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10297376 /
24 if (!browser.webRequest.ResourceType || 24 if (!browser.webRequest.ResourceType ||
25 !("WEBSOCKET" in browser.webRequest.ResourceType)) 25 !("WEBSOCKET" in browser.webRequest.ResourceType))
26 { 26 {
27 const {defaultMatcher} = require("matcher"); 27 const {defaultMatcher} = require("../adblockpluscore/lib/matcher");
28 const {BlockingFilter, RegExpFilter} = require("filterClasses"); 28 const {BlockingFilter, RegExpFilter} =
29 const {getDecodedHostname} = require("url"); 29 require("../adblockpluscore/lib/filterClasses");
30 const {checkWhitelisted} = require("whitelisting"); 30 const {getDecodedHostname} = require("./url");
31 const {checkWhitelisted} = require("./whitelisting");
31 32
32 browser.webRequest.onHeadersReceived.addListener(details => 33 browser.webRequest.onHeadersReceived.addListener(details =>
33 { 34 {
34 let hostname = getDecodedHostname(new URL(details.url)); 35 let hostname = getDecodedHostname(new URL(details.url));
35 let match = defaultMatcher.matchesAny("", RegExpFilter.typeMap.WEBSOCKET, 36 let match = defaultMatcher.matchesAny("", RegExpFilter.typeMap.WEBSOCKET,
36 hostname, false, null, true); 37 hostname, false, null, true);
37 if (match instanceof BlockingFilter && 38 if (match instanceof BlockingFilter &&
38 !checkWhitelisted(new ext.Page({id: details.tabId}), 39 !checkWhitelisted(new ext.Page({id: details.tabId}),
39 ext.getFrame(details.tabId, details.frameId))) 40 ext.getFrame(details.tabId, details.frameId)))
40 { 41 {
(...skipping 19 matching lines...) Expand all
60 } 61 }
61 }, { 62 }, {
62 urls: ["http://*/*", "https://*/*"], 63 urls: ["http://*/*", "https://*/*"],
63 // We must also intercept script requests since otherwise Web Workers can 64 // We must also intercept script requests since otherwise Web Workers can
64 // be abused to execute scripts for which our Content Security Policy 65 // be abused to execute scripts for which our Content Security Policy
65 // won't be injected. 66 // won't be injected.
66 // https://github.com/gorhill/uBO-Extra/issues/19 67 // https://github.com/gorhill/uBO-Extra/issues/19
67 types: ["main_frame", "sub_frame", "script"] 68 types: ["main_frame", "sub_frame", "script"]
68 }, ["blocking", "responseHeaders"]); 69 }, ["blocking", "responseHeaders"]);
69 } 70 }
OLDNEW
« no previous file with comments | « include.preload.js ('k') | lib/cssInjection.js » ('j') | lib/filterComposer.js » ('J')

Powered by Google App Engine
This is Rietveld