| Left: | ||
| Right: |
| LEFT | RIGHT |
|---|---|
| 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 {RegExpFilter} = require("filterClasses"); |
| 22 let {stringifyURL, getDecodedHostname, extractHostFromFrame, isThirdParty} = req uire("url"); | 22 let {stringifyURL, getDecodedHostname, extractHostFromFrame, isThirdParty} = req uire("url"); |
| 23 | 23 |
| 24 let pagesWithKey = new ext.PageMap(); | 24 let pagesWithKey = new ext.PageMap(); |
| 25 | 25 |
| 26 /** | 26 /** |
| 27 * Checks whether a page is whitelisted. | 27 * Checks whether a page is whitelisted. |
| 28 * | 28 * |
| 29 * @param {Page} page | 29 * @param {Page} page |
| 30 * @param {Number} [typeMask=RegExpFilter.typeMap.DOCUMENT] Bit mask of request / content types to match | |
| 31 * @return {WhitelistFilter} The active filter whitelisting this page or null | 30 * @return {WhitelistFilter} The active filter whitelisting this page or null |
| 32 */ | 31 */ |
| 33 exports.isPageWhitelisted = function(page, typeMask) | 32 exports.isPageWhitelisted = function(page) |
|
Sebastian Noack
2015/07/13 16:41:50
Sorry if my previous comment was misleading. But s
kzar
2015/07/14 09:22:24
Done.
| |
| 34 { | 33 { |
| 35 let url = page.url; | 34 let url = page.url; |
| 36 | 35 |
| 37 return defaultMatcher.whitelist.matchesAny( | 36 return defaultMatcher.whitelist.matchesAny( |
| 38 stringifyURL(url), typeMask || RegExpFilter.typeMap.DOCUMENT, | 37 stringifyURL(url), RegExpFilter.typeMap.DOCUMENT, |
| 39 getDecodedHostname(url), false, null | 38 getDecodedHostname(url), false, null |
| 40 ); | 39 ); |
| 41 }; | 40 }; |
| 42 | 41 |
| 43 /** | 42 /** |
| 44 * Checks whether a frame is whitelisted. | 43 * Checks whether a frame is whitelisted. |
| 45 * | 44 * |
| 46 * @param {Page} page | 45 * @param {Page} page |
| 47 * @param {Frame} frame | 46 * @param {Frame} frame |
| 48 * @param {Number} [typeMask=RegExpFilter.typeMap.DOCUMENT] Bit mask of request / content types to match | 47 * @param {number} [typeMask=RegExpFilter.typeMap.DOCUMENT] Bit mask of request / content types to match |
|
Sebastian Noack
2015/07/13 16:41:50
Nit: Please use lowercase when referring to primit
kzar
2015/07/14 09:22:24
Done.
| |
| 49 * @return {Boolean} | 48 * @return {Boolean} |
| 50 */ | 49 */ |
| 51 exports.isFrameWhitelisted = function(page, frame, typeMask) | 50 exports.isFrameWhitelisted = function(page, frame, typeMask) |
| 52 { | 51 { |
| 53 while (frame) | 52 while (frame) |
| 54 { | 53 { |
| 55 let parent = frame.parent; | 54 let parent = frame.parent; |
| 56 let url = frame.url; | 55 let url = frame.url; |
| 57 let documentHost = extractHostFromFrame(parent) || getDecodedHostname(url); | 56 let documentHost = extractHostFromFrame(parent) || getDecodedHostname(url); |
| 58 | 57 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 { | 133 { |
| 135 if (token.indexOf("_") < 0) | 134 if (token.indexOf("_") < 0) |
| 136 return; | 135 return; |
| 137 | 136 |
| 138 let [key, signature] = token.split("_", 2); | 137 let [key, signature] = token.split("_", 2); |
| 139 key = key.replace(/=/g, ""); | 138 key = key.replace(/=/g, ""); |
| 140 | 139 |
| 141 if (verifyKey(key, signature, frame.url)) | 140 if (verifyKey(key, signature, frame.url)) |
| 142 recordKey(page, frame.url, key); | 141 recordKey(page, frame.url, key); |
| 143 }; | 142 }; |
| LEFT | RIGHT |