Left: | ||
Right: |
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-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 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 /** @module whitelisting */ | 18 /** @module whitelisting */ |
19 | 19 |
20 let {defaultMatcher} = require("matcher"); | 20 let {defaultMatcher} = require("matcher"); |
21 let {RegExpFilter} = require("filterClasses"); | |
21 let {stringifyURL, getDecodedHostname, extractHostFromFrame, isThirdParty} = req uire("url"); | 22 let {stringifyURL, getDecodedHostname, extractHostFromFrame, isThirdParty} = req uire("url"); |
22 | 23 |
23 let pagesWithKey = new ext.PageMap(); | 24 let pagesWithKey = new ext.PageMap(); |
24 | 25 |
25 /** | 26 /** |
26 * Checks whether a page is whitelisted. | 27 * Checks whether a page is whitelisted. |
27 * | 28 * |
28 * @param {Page} page | 29 * @param {Page} page |
29 * @return {WhitelistFilter} The active filter whitelisting this page or null | 30 * @return {WhitelistFilter} The active filter whitelisting this page or null |
30 */ | 31 */ |
31 exports.isPageWhitelisted = function(page) | 32 exports.isPageWhitelisted = function(page) |
32 { | 33 { |
33 let url = page.url; | 34 let url = page.url; |
34 | 35 |
35 return defaultMatcher.whitelist.matchesAny( | 36 return defaultMatcher.whitelist.matchesAny( |
36 stringifyURL(url), "DOCUMENT", | 37 stringifyURL(url), RegExpFilter.toTypeMask("DOCUMENT"), |
37 getDecodedHostname(url), false, null | 38 getDecodedHostname(url), false, null |
38 ); | 39 ); |
39 }; | 40 }; |
40 | 41 |
41 /** | 42 /** |
42 * Checks whether a frame is whitelisted. | 43 * Checks whether a frame is whitelisted. |
43 * | 44 * |
44 * @param {Page} page | 45 * @param {Page} page |
45 * @param {Frame} frame | 46 * @param {Frame} frame |
46 * @param {string} [type=DOCUMENT] The request type to check whether | 47 * @param {string} [type=DOCUMENT] The request type to check whether |
47 * the frame is whitelisted for. | 48 * the frame is whitelisted for. |
48 * @return {Boolean} | 49 * @return {Boolean} |
49 */ | 50 */ |
50 exports.isFrameWhitelisted = function(page, frame, type) | 51 exports.isFrameWhitelisted = function(page, frame, type) |
51 { | 52 { |
52 while (frame) | 53 while (frame) |
53 { | 54 { |
54 let parent = frame.parent; | 55 let parent = frame.parent; |
55 let url = frame.url; | 56 let url = frame.url; |
56 let documentHost = extractHostFromFrame(parent) || getDecodedHostname(url); | 57 let documentHost = extractHostFromFrame(parent) || getDecodedHostname(url); |
57 | 58 |
58 let filter = defaultMatcher.whitelist.matchesAny( | 59 let filter = defaultMatcher.whitelist.matchesAny( |
59 stringifyURL(url), type || "DOCUMENT", | 60 stringifyURL(url), RegExpFilter.toTypeMask(type || "DOCUMENT"), |
Sebastian Noack
2015/07/09 15:28:52
And here as well.
kzar
2015/07/12 14:28:01
Done.
| |
60 documentHost, isThirdParty(url, documentHost), | 61 documentHost, isThirdParty(url, documentHost), |
61 getKey(page, frame) | 62 getKey(page, frame) |
62 ); | 63 ); |
63 | 64 |
64 if (filter) | 65 if (filter) |
65 return true; | 66 return true; |
66 | 67 |
67 frame = parent; | 68 frame = parent; |
68 } | 69 } |
69 | 70 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
133 { | 134 { |
134 if (token.indexOf("_") < 0) | 135 if (token.indexOf("_") < 0) |
135 return; | 136 return; |
136 | 137 |
137 let [key, signature] = token.split("_", 2); | 138 let [key, signature] = token.split("_", 2); |
138 key = key.replace(/=/g, ""); | 139 key = key.replace(/=/g, ""); |
139 | 140 |
140 if (verifyKey(key, signature, frame.url)) | 141 if (verifyKey(key, signature, frame.url)) |
141 recordKey(page, frame.url, key); | 142 recordKey(page, frame.url, key); |
142 }; | 143 }; |
OLD | NEW |