Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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 let hasLeadingWildcard = (source[0] == "*"); | 495 .replace(/\W/g, "\\$&") // escape special symbols |
496 if (hasLeadingWildcard) | 496 .replace(/\\\*/g, ".*") // replace wildcards by .* |
497 source = source.substr(1); | 497 // process separator placeholders (all ANSI characters but alphanumeric ch aracters and _%.-) |
498 | 498 .replace(/\\\^/g, "(?:[\\x00-\\x24\\x26-\\x2C\\x2F\\x3A-\\x40\\x5B-\\x5E\\ x60\\x7B-\\x80]|$)") |
Wladimir Palant
2014/01/27 14:06:53
Nothing wrong with having \\x7F instead of \\x80 h
| |
499 // Remove trailing wildcards | 499 .replace(/^\\\|\\\|/, "^[\\w\\-]+:\\/+(?!\\/)(?:[^\\/]+\\.)?") // process extended anchor at expression start |
500 let pos = source.length - 1; | 500 .replace(/^\\\|/, "^") // process anchor at expression start |
501 let hasTrailingWildcard = (pos >= 0 && source[pos] == "*"); | 501 .replace(/\\\|$/, "$") // process anchor at expression end |
502 if (hasTrailingWildcard) | 502 .replace(/^(\.\*)/, "") // remove leading wildcards |
503 source = source.substr(0, pos); | 503 .replace(/(\.\*)$/, ""); // remove trailing wildcards |
504 | |
505 source = source.replace(/\^\|$/, "^") // remove anchors following separator placeholder | |
506 .replace(/\W/g, "\\$&") // escape special symbols | |
507 .replace(/\\\*/g, ".*") // replace wildcards by .* | |
508 // process separator placeholders (all ANSI characters but al phanumeric characters and _%.-) | |
509 .replace(/\\\^/g, "(?:[\\x00-\\x24\\x26-\\x2C\\x2F\\x3A-\\x40 \\x5B-\\x5E\\x60\\x7B-\\x7F]|$)"); | |
510 if (!hasLeadingWildcard) | |
511 source = source.replace(/^\\\|\\\|/, "^[\\w\\-]+:\\/+(?!\\/)(?:[^.\\/]+\\. )*?") // process extended anchor at expression start | |
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
| |
515 | 504 |
516 let regexp = new RegExp(source, this.matchCase ? "" : "i"); | 505 let regexp = new RegExp(source, this.matchCase ? "" : "i"); |
517 | 506 |
518 delete this.regexpSource; | 507 delete this.regexpSource; |
519 this.__defineGetter__("regexp", function() regexp); | 508 this.__defineGetter__("regexp", function() regexp); |
520 return this.regexp; | 509 return this.regexp; |
521 }, | 510 }, |
522 /** | 511 /** |
523 * 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 |
524 * @type Number | 513 * @type Number |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
876 function ElemHideException(text, domains, selector) | 865 function ElemHideException(text, domains, selector) |
877 { | 866 { |
878 ElemHideBase.call(this, text, domains, selector); | 867 ElemHideBase.call(this, text, domains, selector); |
879 } | 868 } |
880 exports.ElemHideException = ElemHideException; | 869 exports.ElemHideException = ElemHideException; |
881 | 870 |
882 ElemHideException.prototype = | 871 ElemHideException.prototype = |
883 { | 872 { |
884 __proto__: ElemHideBase.prototype | 873 __proto__: ElemHideBase.prototype |
885 }; | 874 }; |
LEFT | RIGHT |