Left: | ||
Right: |
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 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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.replace(/\*+/g, "*"); |
493 | 493 |
494 // Remove leading wildcards | 494 // Remove leading wildcards |
495 if (source[0] == "*") | 495 let hasLeadingWildcard = (source[0] == "*"); |
496 if (hasLeadingWildcard) | |
496 source = source.substr(1); | 497 source = source.substr(1); |
497 | 498 |
498 // Remove trailing wildcards | 499 // Remove trailing wildcards |
499 let pos = source.length - 1; | 500 let pos = source.length - 1; |
500 if (pos >= 0 && source[pos] == "*") | 501 let hasTrailingWildcard = (pos >= 0 && source[pos] == "*"); |
502 if (hasTrailingWildcard) | |
501 source = source.substr(0, pos); | 503 source = source.substr(0, pos); |
502 | 504 |
503 source = source.replace(/\^\|$/, "^") // remove anchors following sepa rator placeholder | 505 source = source.replace(/\^\|$/, "^") // remove anchors following separator placeholder |
504 .replace(/\W/g, "\\$&") // escape special symbols | 506 .replace(/\W/g, "\\$&") // escape special symbols |
505 .replace(/\\\*/g, ".*") // replace wildcards by .* | 507 .replace(/\\\*/g, ".*") // replace wildcards by .* |
506 // process separator placeholders (all ANSI charaters but alp hanumeric characters and _%.-) | 508 // process separator placeholders (all ANSI characters but al phanumeric characters and _%.-) |
507 .replace(/\\\^/g, "(?:[\\x00-\\x24\\x26-\\x2C\\x2F\\x3A-\\x40 \\x5B-\\x5E\\x60\\x7B-\\x80]|$)") | 509 .replace(/\\\^/g, "(?:[\\x00-\\x24\\x26-\\x2C\\x2F\\x3A-\\x40 \\x5B-\\x5E\\x60\\x7B-\\x7F]|$)"); |
508 .replace(/^\\\|\\\|/, "^[\\w\\-]+:\\/+(?!\\/)(?:[^.\\/]+\\.)* ?") // process extended anchor at expression start | 510 if (!hasLeadingWildcard) |
509 .replace(/^\\\|/, "^") // process anchor at expression start | 511 source = source.replace(/^\\\|\\\|/, "^[\\w\\-]+:\\/+(?!\\/)(?:[^.\\/]+\\. )*?") // process extended anchor at expression start |
510 .replace(/\\\|$/, "$"); // process anchor at expression end | 512 .replace(/^\\\|/, "^"); // process anchor at expression sta rt |
513 if (!hasTrailingWildcard) | |
514 source = source.replace(/\\\|$/, "$"); // process anchor at expression end | |
Wladimir Palant
2014/01/24 13:11:32
This issue was introduced in the speedup here: htt
Thomas Greiner
2014/01/24 14:48:16
Done. If we still want to optimize the performance
| |
511 | 515 |
512 let regexp = new RegExp(source, this.matchCase ? "" : "i"); | 516 let regexp = new RegExp(source, this.matchCase ? "" : "i"); |
513 | 517 |
514 delete this.regexpSource; | 518 delete this.regexpSource; |
515 this.__defineGetter__("regexp", function() regexp); | 519 this.__defineGetter__("regexp", function() regexp); |
516 return this.regexp; | 520 return this.regexp; |
517 }, | 521 }, |
518 /** | 522 /** |
519 * Content types the filter applies to, combination of values from RegExpFilte r.typeMap | 523 * Content types the filter applies to, combination of values from RegExpFilte r.typeMap |
520 * @type Number | 524 * @type Number |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
872 function ElemHideException(text, domains, selector) | 876 function ElemHideException(text, domains, selector) |
873 { | 877 { |
874 ElemHideBase.call(this, text, domains, selector); | 878 ElemHideBase.call(this, text, domains, selector); |
875 } | 879 } |
876 exports.ElemHideException = ElemHideException; | 880 exports.ElemHideException = ElemHideException; |
877 | 881 |
878 ElemHideException.prototype = | 882 ElemHideException.prototype = |
879 { | 883 { |
880 __proto__: ElemHideBase.prototype | 884 __proto__: ElemHideBase.prototype |
881 }; | 885 }; |
OLD | NEW |