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-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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
172 * @param {string} location | 172 * @param {string} location |
173 * @param {number} typeMask | 173 * @param {number} typeMask |
174 * @param {string} [docDomain] | 174 * @param {string} [docDomain] |
175 * @param {boolean} [thirdParty] | 175 * @param {boolean} [thirdParty] |
176 * @param {string} [sitekey] | 176 * @param {string} [sitekey] |
177 * @param {boolean} [specificOnly] | 177 * @param {boolean} [specificOnly] |
178 * @returns {?Filter} | 178 * @returns {?Filter} |
179 * @protected | 179 * @protected |
180 */ | 180 */ |
181 checkEntryMatch(keyword, location, typeMask, docDomain, thirdParty, sitekey, | 181 checkEntryMatch(keyword, location, typeMask, docDomain, thirdParty, sitekey, |
182 specificOnly) | 182 specificOnly) |
183 { | 183 { |
184 let set = this._filterByKeyword.get(keyword); | 184 let set = this._filterByKeyword.get(keyword); |
185 if (typeof set == "undefined") | 185 if (typeof set == "undefined") |
186 return null; | 186 return null; |
187 | 187 |
188 for (let filter of set) | 188 for (let filter of set) |
189 { | 189 { |
190 if (specificOnly && filter.isGeneric() && | 190 if (specificOnly && filter.isGeneric() && |
191 !(filter instanceof WhitelistFilter)) | 191 !(filter instanceof WhitelistFilter)) |
192 continue; | 192 continue; |
(...skipping 23 matching lines...) Expand all Loading... | |
216 */ | 216 */ |
217 matchesAny(location, typeMask, docDomain, thirdParty, sitekey, specificOnly) | 217 matchesAny(location, typeMask, docDomain, thirdParty, sitekey, specificOnly) |
218 { | 218 { |
219 let candidates = location.toLowerCase().match(/[a-z0-9%]{3,}/g); | 219 let candidates = location.toLowerCase().match(/[a-z0-9%]{3,}/g); |
220 if (candidates === null) | 220 if (candidates === null) |
221 candidates = []; | 221 candidates = []; |
222 candidates.push(""); | 222 candidates.push(""); |
223 for (let i = 0, l = candidates.length; i < l; i++) | 223 for (let i = 0, l = candidates.length; i < l; i++) |
224 { | 224 { |
225 let result = this.checkEntryMatch(candidates[i], location, typeMask, | 225 let result = this.checkEntryMatch(candidates[i], location, typeMask, |
226 docDomain, thirdParty, sitekey, | 226 docDomain, thirdParty, sitekey, |
Manish Jethani
2018/10/23 10:38:27
The following lines are not properly aligned now.
Jon Sonesen
2018/10/23 17:39:47
Done.
| |
227 specificOnly); | 227 specificOnly); |
228 if (result) | 228 if (result) |
229 return result; | 229 return result; |
230 } | 230 } |
231 | 231 |
232 return null; | 232 return null; |
233 } | 233 } |
234 } | 234 } |
235 | 235 |
236 exports.Matcher = Matcher; | 236 exports.Matcher = Matcher; |
237 | 237 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
324 | 324 |
325 /** | 325 /** |
326 * Optimized filter matching testing both whitelist and blacklist matchers | 326 * Optimized filter matching testing both whitelist and blacklist matchers |
327 * simultaneously. For parameters see | 327 * simultaneously. For parameters see |
328 {@link Matcher#matchesAny Matcher.matchesAny()}. | 328 {@link Matcher#matchesAny Matcher.matchesAny()}. |
329 * @see Matcher#matchesAny | 329 * @see Matcher#matchesAny |
330 * @inheritdoc | 330 * @inheritdoc |
331 * @private | 331 * @private |
332 */ | 332 */ |
333 _matchesAnyInternal(location, typeMask, docDomain, thirdParty, sitekey, | 333 _matchesAnyInternal(location, typeMask, docDomain, thirdParty, sitekey, |
334 specificOnly) | 334 specificOnly) |
Manish Jethani
2018/10/23 10:38:27
Not properly aligned.
Jon Sonesen
2018/10/23 17:39:47
Done.
| |
335 { | 335 { |
336 let candidates = location.toLowerCase().match(/[a-z0-9%]{3,}/g); | 336 let candidates = location.toLowerCase().match(/[a-z0-9%]{3,}/g); |
337 if (candidates === null) | 337 if (candidates === null) |
338 candidates = []; | 338 candidates = []; |
339 candidates.push(""); | 339 candidates.push(""); |
340 | 340 |
341 let whitelistHit = null; | 341 let whitelistHit = null; |
342 let blacklistHit = null; | 342 let blacklistHit = null; |
343 | 343 |
344 // If the type mask includes no types other than whitelist-only types, we | 344 // If the type mask includes no types other than whitelist-only types, we |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
376 matchesAny(location, typeMask, docDomain, thirdParty, sitekey, specificOnly) | 376 matchesAny(location, typeMask, docDomain, thirdParty, sitekey, specificOnly) |
377 { | 377 { |
378 let key = location + " " + typeMask + " " + docDomain + " " + thirdParty + | 378 let key = location + " " + typeMask + " " + docDomain + " " + thirdParty + |
379 " " + sitekey + " " + specificOnly; | 379 " " + sitekey + " " + specificOnly; |
380 | 380 |
381 let result = this._resultCache.get(key); | 381 let result = this._resultCache.get(key); |
382 if (typeof result != "undefined") | 382 if (typeof result != "undefined") |
383 return result; | 383 return result; |
384 | 384 |
385 result = this._matchesAnyInternal(location, typeMask, docDomain, | 385 result = this._matchesAnyInternal(location, typeMask, docDomain, |
386 thirdParty, sitekey, specificOnly); | 386 thirdParty, sitekey, specificOnly); |
Manish Jethani
2018/10/23 10:38:27
Not properly aligned.
Jon Sonesen
2018/10/23 17:39:47
Done.
| |
387 | 387 |
388 if (this._resultCache.size >= this.maxCacheEntries) | 388 if (this._resultCache.size >= this.maxCacheEntries) |
389 this._resultCache.clear(); | 389 this._resultCache.clear(); |
390 | 390 |
391 this._resultCache.set(key, result); | 391 this._resultCache.set(key, result); |
392 | 392 |
393 return result; | 393 return result; |
394 } | 394 } |
395 } | 395 } |
396 | 396 |
397 exports.CombinedMatcher = CombinedMatcher; | 397 exports.CombinedMatcher = CombinedMatcher; |
398 | 398 |
399 /** | 399 /** |
400 * Shared {@link CombinedMatcher} instance that should usually be used. | 400 * Shared {@link CombinedMatcher} instance that should usually be used. |
401 * @type {CombinedMatcher} | 401 * @type {CombinedMatcher} |
402 */ | 402 */ |
403 let defaultMatcher = new CombinedMatcher(); | 403 let defaultMatcher = new CombinedMatcher(); |
404 | 404 |
405 exports.defaultMatcher = defaultMatcher; | 405 exports.defaultMatcher = defaultMatcher; |
LEFT | RIGHT |