OLD | NEW |
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 if (checkWhitelisted(page, frame)) | 44 if (checkWhitelisted(page, frame)) |
45 return; | 45 return; |
46 | 46 |
47 // To avoid an extra matchesAny for the common case we assumed no | 47 // To avoid an extra matchesAny for the common case we assumed no |
48 // $genericblock filters applied when searching for a matching $csp filter. | 48 // $genericblock filters applied when searching for a matching $csp filter. |
49 // We must now pay the price by first checking for a $genericblock filter | 49 // We must now pay the price by first checking for a $genericblock filter |
50 // and if necessary that our $csp filter is specific. | 50 // and if necessary that our $csp filter is specific. |
51 let specificOnly = !!checkWhitelisted(page, frame, null, | 51 let specificOnly = !!checkWhitelisted(page, frame, null, |
52 typeMap.GENERICBLOCK); | 52 typeMap.GENERICBLOCK); |
53 if (specificOnly) | 53 if (specificOnly && !(cspMatch instanceof WhitelistFilter)) |
54 { | 54 { |
55 cspMatch = defaultMatcher.matchesAny(details.url, typeMap.CSP, hostname, | 55 cspMatch = defaultMatcher.matchesAny(details.url, typeMap.CSP, hostname, |
56 thirdParty, null, specificOnly); | 56 thirdParty, null, specificOnly); |
57 if (!cspMatch) | 57 if (!cspMatch) |
58 return; | 58 return; |
59 } | 59 } |
60 | 60 |
61 logRequest([details.tabId], { | 61 logRequest([details.tabId], { |
62 url: details.url, type: "CSP", docDomain: hostname, | 62 url: details.url, type: "CSP", docDomain: hostname, |
63 thirdParty, specificOnly | 63 thirdParty, specificOnly |
64 }, cspMatch); | 64 }, cspMatch); |
65 filterNotifier.emit("filter.hitCount", cspMatch, 0, 0, [details.tabId]); | 65 filterNotifier.emit("filter.hitCount", cspMatch, 0, 0, [details.tabId]); |
66 | 66 |
67 if (cspMatch instanceof WhitelistFilter) | 67 if (cspMatch instanceof WhitelistFilter) |
68 return; | 68 return; |
69 | 69 |
70 details.responseHeaders.push({ | 70 details.responseHeaders.push({ |
71 name: "Content-Security-Policy", | 71 name: "Content-Security-Policy", |
72 value: cspMatch.csp | 72 value: cspMatch.csp |
73 }); | 73 }); |
74 | 74 |
75 return {responseHeaders: details.responseHeaders}; | 75 return {responseHeaders: details.responseHeaders}; |
76 } | 76 } |
77 }, { | 77 }, { |
78 urls: ["http://*/*", "https://*/*"], | 78 urls: ["http://*/*", "https://*/*"], |
79 types: ["main_frame", "sub_frame"] | 79 types: ["main_frame", "sub_frame"] |
80 }, ["blocking", "responseHeaders"]); | 80 }, ["blocking", "responseHeaders"]); |
OLD | NEW |