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

Delta Between Two Patch Sets: lib/csp.js

Issue 29458601: Issue 5315 - Add support for Microsoft Edge (Closed)
Left Patch Set: Created June 7, 2017, 12:41 p.m.
Right Patch Set: Cosmetic changes Created July 28, 2017, 11:02 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « inject.preload.js ('k') | lib/filterComposer.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
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-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 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 // Before Chrome 58, the webRequest API did not intercept WebSocket 20 // The webRequest API doesn't support WebSocket connection blocking in Microsoft
21 // connections (see https://crbug.com/129353). Hence we inject CSP headers, 21 // Edge and versions of Chrome before 58. Therefore for those we inject CSP
22 // below, as a workaround. 22 // headers below as a workaround. See https://crbug.com/129353 and
23 if (!("WEBSOCKET" in chrome.webRequest.ResourceType)) 23 // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10297376 /
24 if (!chrome.webRequest.ResourceType ||
25 !("WEBSOCKET" in chrome.webRequest.ResourceType))
24 { 26 {
25 const {defaultMatcher} = require("matcher"); 27 const {defaultMatcher} = require("matcher");
26 const {BlockingFilter, RegExpFilter} = require("filterClasses"); 28 const {BlockingFilter, RegExpFilter} = require("filterClasses");
27 const {getDecodedHostname} = require("url"); 29 const {getDecodedHostname} = require("url");
28 const {checkWhitelisted} = require("whitelisting"); 30 const {checkWhitelisted} = require("whitelisting");
29 31
30 chrome.webRequest.onHeadersReceived.addListener(details => 32 chrome.webRequest.onHeadersReceived.addListener(details =>
31 { 33 {
32 let hostname = getDecodedHostname(new URL(details.url)); 34 let hostname = getDecodedHostname(new URL(details.url));
33 let match = defaultMatcher.matchesAny("", RegExpFilter.typeMap.WEBSOCKET, 35 let match = defaultMatcher.matchesAny("", RegExpFilter.typeMap.WEBSOCKET,
(...skipping 24 matching lines...) Expand all
58 } 60 }
59 }, { 61 }, {
60 urls: ["http://*/*", "https://*/*"], 62 urls: ["http://*/*", "https://*/*"],
61 // We must also intercept script requests since otherwise Web Workers can 63 // We must also intercept script requests since otherwise Web Workers can
62 // be abused to execute scripts for which our Content Security Policy 64 // be abused to execute scripts for which our Content Security Policy
63 // won't be injected. 65 // won't be injected.
64 // https://github.com/gorhill/uBO-Extra/issues/19 66 // https://github.com/gorhill/uBO-Extra/issues/19
65 types: ["main_frame", "sub_frame", "script"] 67 types: ["main_frame", "sub_frame", "script"]
66 }, ["blocking", "responseHeaders"]); 68 }, ["blocking", "responseHeaders"]);
67 } 69 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld