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

Delta Between Two Patch Sets: lib/whitelisting.js

Issue 29321504: Issue 2738 - Pass bit masks to matching functions (Closed)
Left Patch Set: Created July 9, 2015, 2:50 p.m.
Right Patch Set: Updated adblockplus dependency Created July 14, 2015, 2:45 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 | « lib/filterComposer.js ('k') | popupBlocker.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-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
(...skipping 16 matching lines...) Expand all
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 * @return {WhitelistFilter} The active filter whitelisting this page or null 30 * @return {WhitelistFilter} The active filter whitelisting this page or null
31 */ 31 */
32 exports.isPageWhitelisted = function(page) 32 exports.isPageWhitelisted = function(page)
33 { 33 {
34 let url = page.url; 34 let url = page.url;
35 35
36 return defaultMatcher.whitelist.matchesAny( 36 return defaultMatcher.whitelist.matchesAny(
37 stringifyURL(url), RegExpFilter.toTypeMask("DOCUMENT"), 37 stringifyURL(url), RegExpFilter.typeMap.DOCUMENT,
38 getDecodedHostname(url), false, null 38 getDecodedHostname(url), false, null
39 ); 39 );
40 }; 40 };
41 41
42 /** 42 /**
43 * Checks whether a frame is whitelisted. 43 * Checks whether a frame is whitelisted.
44 * 44 *
45 * @param {Page} page 45 * @param {Page} page
46 * @param {Frame} frame 46 * @param {Frame} frame
47 * @param {string} [type=DOCUMENT] The request type to check whether 47 * @param {number} [typeMask=RegExpFilter.typeMap.DOCUMENT] Bit mask of request / content types to match
48 * the frame is whitelisted for.
49 * @return {Boolean} 48 * @return {Boolean}
50 */ 49 */
51 exports.isFrameWhitelisted = function(page, frame, type) 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
59 let filter = defaultMatcher.whitelist.matchesAny( 58 let filter = defaultMatcher.whitelist.matchesAny(
60 stringifyURL(url), RegExpFilter.toTypeMask(type || "DOCUMENT"), 59 stringifyURL(url), typeMask || RegExpFilter.typeMap.DOCUMENT,
Sebastian Noack 2015/07/09 15:28:52 And here as well.
kzar 2015/07/12 14:28:01 Done.
61 documentHost, isThirdParty(url, documentHost), 60 documentHost, isThirdParty(url, documentHost),
62 getKey(page, frame) 61 getKey(page, frame)
63 ); 62 );
64 63
65 if (filter) 64 if (filter)
66 return true; 65 return true;
67 66
68 frame = parent; 67 frame = parent;
69 } 68 }
70 69
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld