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

Side by Side Diff: lib/csp.js

Issue 29739594: Issue 6543 - Match requests without tabId/frameId in their originating context (Closed)
Patch Set: Use URL patterns to find tabs for initiator Created April 4, 2018, 1:01 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | lib/cssInjection.js » ('j') | lib/requestBlocker.js » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 let page = new ext.Page({id: details.tabId, url: details.url}); 42 let page = new ext.Page({id: details.tabId, url: details.url});
43 let frame = ext.getFrame(details.tabId, details.frameId); 43 let frame = ext.getFrame(details.tabId, details.frameId);
44 44
45 if (checkWhitelisted(page, frame)) 45 if (checkWhitelisted(page, frame))
46 return; 46 return;
47 47
48 // To avoid an extra matchesAny for the common case we assumed no 48 // To avoid an extra matchesAny for the common case we assumed no
49 // $genericblock filters applied when searching for a matching $csp filter. 49 // $genericblock filters applied when searching for a matching $csp filter.
50 // We must now pay the price by first checking for a $genericblock filter 50 // We must now pay the price by first checking for a $genericblock filter
51 // and if necessary that our $csp filter is specific. 51 // and if necessary that our $csp filter is specific.
52 let specificOnly = !!checkWhitelisted(page, frame, typeMap.GENERICBLOCK); 52 let specificOnly = !!checkWhitelisted(page, frame, null,
53 typeMap.GENERICBLOCK);
53 if (specificOnly) 54 if (specificOnly)
54 { 55 {
55 cspMatch = defaultMatcher.matchesAny(urlString, typeMap.CSP, hostname, 56 cspMatch = defaultMatcher.matchesAny(urlString, typeMap.CSP, hostname,
56 thirdParty, null, specificOnly); 57 thirdParty, null, specificOnly);
57 if (!cspMatch) 58 if (!cspMatch)
58 return; 59 return;
59 } 60 }
60 61
61 devtools.logRequest([details.tabId], urlString, "CSP", hostname, 62 devtools.logRequest([details.tabId], urlString, "CSP", hostname,
62 thirdParty, null, specificOnly, cspMatch); 63 thirdParty, null, specificOnly, cspMatch);
63 FilterNotifier.emit("filter.hitCount", cspMatch, 0, 0, [details.tabId]); 64 FilterNotifier.emit("filter.hitCount", cspMatch, 0, 0, [details.tabId]);
64 65
65 if (cspMatch instanceof WhitelistFilter) 66 if (cspMatch instanceof WhitelistFilter)
66 return; 67 return;
67 68
68 details.responseHeaders.push({ 69 details.responseHeaders.push({
69 name: "Content-Security-Policy", 70 name: "Content-Security-Policy",
70 value: cspMatch.csp 71 value: cspMatch.csp
71 }); 72 });
72 73
73 return {responseHeaders: details.responseHeaders}; 74 return {responseHeaders: details.responseHeaders};
74 } 75 }
75 }, { 76 }, {
76 urls: ["http://*/*", "https://*/*"], 77 urls: ["http://*/*", "https://*/*"],
77 types: ["main_frame", "sub_frame"] 78 types: ["main_frame", "sub_frame"]
78 }, ["blocking", "responseHeaders"]); 79 }, ["blocking", "responseHeaders"]);
OLDNEW
« no previous file with comments | « no previous file | lib/cssInjection.js » ('j') | lib/requestBlocker.js » ('J')

Powered by Google App Engine
This is Rietveld