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

Delta Between Two Patch Sets: lib/csp.js

Issue 29394585: Issue 5027 - Use updated webRequest API for WebSocket blocking (Closed)
Left Patch Set: change comment grammer, fix line wrapping Created March 28, 2017, 8:07 p.m.
Right Patch Set: change commit message, add chrome version to include.preload.js comments Created March 29, 2017, 12:04 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « include.preload.js ('k') | lib/requestBlocker.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
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 // Before Chrome 58, the webRequest API did not intercept WebSocket
21 // connections see: https://crbug.com/129353. Hence we inject CSP headers, 21 // connections (see https://crbug.com/129353). Hence we inject CSP headers,
Jon Sonesen 2017/03/28 20:10:31 Perhaps I should remove the colon.
Sebastian Noack 2017/03/28 20:20:43 I wouldn't insist, but personally I'd omit the col
Jon Sonesen 2017/03/28 21:33:02 I prefer the way the parentheses look too, so I ha
22 // below, as a workaround. 22 // below, as a workaround.
23 if (!("WEBSOCKET" in chrome.webRequest.ResourceType)) 23 if (!("WEBSOCKET" in chrome.webRequest.ResourceType))
24 { 24 {
25 const {defaultMatcher} = require("matcher"); 25 const {defaultMatcher} = require("matcher");
26 const {BlockingFilter, RegExpFilter} = require("filterClasses"); 26 const {BlockingFilter, RegExpFilter} = require("filterClasses");
27 const {getDecodedHostname} = require("url"); 27 const {getDecodedHostname} = require("url");
28 const {checkWhitelisted} = require("whitelisting"); 28 const {checkWhitelisted} = require("whitelisting");
29 29
30 chrome.webRequest.onHeadersReceived.addListener(details => 30 chrome.webRequest.onHeadersReceived.addListener(details =>
31 { 31 {
(...skipping 25 matching lines...) Expand all
57 } 57 }
58 }, { 58 }, {
59 urls: ["http://*/*", "https://*/*"], 59 urls: ["http://*/*", "https://*/*"],
60 // We must also intercept script requests since otherwise Web Workers can 60 // We must also intercept script requests since otherwise Web Workers can
61 // be abused to execute scripts for which our Content Security Policy 61 // be abused to execute scripts for which our Content Security Policy
62 // won't be injected. 62 // won't be injected.
63 // https://github.com/gorhill/uBO-Extra/issues/19 63 // https://github.com/gorhill/uBO-Extra/issues/19
64 types: ["main_frame", "sub_frame", "script"] 64 types: ["main_frame", "sub_frame", "script"]
65 }, ["blocking", "responseHeaders"]); 65 }, ["blocking", "responseHeaders"]);
66 } 66 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld