OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
3 * Copyright (C) 2006-2013 Eyeo GmbH | 3 * Copyright (C) 2006-2013 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 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 * @type String | 482 * @type String |
483 */ | 483 */ |
484 regexpSource: null, | 484 regexpSource: null, |
485 /** | 485 /** |
486 * Regular expression to be used when testing against this filter | 486 * Regular expression to be used when testing against this filter |
487 * @type RegExp | 487 * @type RegExp |
488 */ | 488 */ |
489 get regexp() | 489 get regexp() |
490 { | 490 { |
491 // Remove multiple wildcards | 491 // Remove multiple wildcards |
492 let source = this.regexpSource.replace(/\*+/g, "*"); | 492 let source = this.regexpSource |
493 | 493 .replace(/\*+/g, "*") // remove multiple wildcards |
494 // Remove leading wildcards | 494 .replace(/\^\|$/, "^") // remove anchors following separator placeho
lder |
495 if (source[0] == "*") | 495 .replace(/\W/g, "\\$&") // escape special symbols |
496 source = source.substr(1); | 496 .replace(/\\\*/g, ".*") // replace wildcards by .* |
497 | 497 // process separator placeholders (all ANSI characters but alphanumeric ch
aracters and _%.-) |
498 // Remove trailing wildcards | 498 .replace(/\\\^/g, "(?:[\\x00-\\x24\\x26-\\x2C\\x2F\\x3A-\\x40\\x5B-\\x5E\\
x60\\x7B-\\x80]|$)") |
499 let pos = source.length - 1; | 499 .replace(/^\\\|\\\|/, "^[\\w\\-]+:\\/+(?!\\/)(?:[^\\/]+\\.)?") // process
extended anchor at expression start |
500 if (pos >= 0 && source[pos] == "*") | 500 .replace(/^\\\|/, "^") // process anchor at expression start |
501 source = source.substr(0, pos); | 501 .replace(/\\\|$/, "$") // process anchor at expression end |
502 | 502 .replace(/^(\.\*)/, "") // remove leading wildcards |
503 source = source.replace(/\^\|$/, "^") // remove anchors following sepa
rator placeholder | 503 .replace(/(\.\*)$/, ""); // remove trailing wildcards |
504 .replace(/\W/g, "\\$&") // escape special symbols | |
505 .replace(/\\\*/g, ".*") // replace wildcards by .* | |
506 // process separator placeholders (all ANSI charaters but alp
hanumeric characters and _%.-) | |
507 .replace(/\\\^/g, "(?:[\\x00-\\x24\\x26-\\x2C\\x2F\\x3A-\\x40
\\x5B-\\x5E\\x60\\x7B-\\x80]|$)") | |
508 .replace(/^\\\|\\\|/, "^[\\w\\-]+:\\/+(?!\\/)(?:[^.\\/]+\\.)*
?") // process extended anchor at expression start | |
509 .replace(/^\\\|/, "^") // process anchor at expression
start | |
510 .replace(/\\\|$/, "$"); // process anchor at expression
end | |
511 | 504 |
512 let regexp = new RegExp(source, this.matchCase ? "" : "i"); | 505 let regexp = new RegExp(source, this.matchCase ? "" : "i"); |
513 | 506 |
514 delete this.regexpSource; | 507 delete this.regexpSource; |
515 this.__defineGetter__("regexp", function() regexp); | 508 this.__defineGetter__("regexp", function() regexp); |
516 return this.regexp; | 509 return this.regexp; |
517 }, | 510 }, |
518 /** | 511 /** |
519 * Content types the filter applies to, combination of values from RegExpFilte
r.typeMap | 512 * Content types the filter applies to, combination of values from RegExpFilte
r.typeMap |
520 * @type Number | 513 * @type Number |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
872 function ElemHideException(text, domains, selector) | 865 function ElemHideException(text, domains, selector) |
873 { | 866 { |
874 ElemHideBase.call(this, text, domains, selector); | 867 ElemHideBase.call(this, text, domains, selector); |
875 } | 868 } |
876 exports.ElemHideException = ElemHideException; | 869 exports.ElemHideException = ElemHideException; |
877 | 870 |
878 ElemHideException.prototype = | 871 ElemHideException.prototype = |
879 { | 872 { |
880 __proto__: ElemHideBase.prototype | 873 __proto__: ElemHideBase.prototype |
881 }; | 874 }; |
OLD | NEW |