Left: | ||
Right: |
OLD | NEW |
---|---|
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-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
78 /** | 78 /** |
79 * Cache for known filters, maps string representation to filter objects. | 79 * Cache for known filters, maps string representation to filter objects. |
80 * @type Object | 80 * @type Object |
81 */ | 81 */ |
82 Filter.knownFilters = Object.create(null); | 82 Filter.knownFilters = Object.create(null); |
83 | 83 |
84 /** | 84 /** |
85 * Regular expression that element hiding filters should match | 85 * Regular expression that element hiding filters should match |
86 * @type RegExp | 86 * @type RegExp |
87 */ | 87 */ |
88 Filter.elemhideRegExp = /^([^\/\*\|\@"!]*?)#(\@)?(?:([\w\-]+|\*)((?:\([\w\-]+(?: [$^*]?=[^\(\)"]*)?\))*)|#([^{}]+))$/; | 88 Filter.elemhideRegExp = /^([^\/\*\|\@"!]*?)#(\@)?(?:([\w\-]+|\*)((?:\([\w\-]+(?: [$^*]?=[^\(\)"]*)?\))*)|#(.+))$/; |
89 /** | 89 /** |
90 * Regular expression that RegExp filters specified as RegExps should match | 90 * Regular expression that RegExp filters specified as RegExps should match |
91 * @type RegExp | 91 * @type RegExp |
92 */ | 92 */ |
93 Filter.regexpRegExp = /^(@@)?\/.*\/(?:\$~?[\w\-]+(?:=[^,\s]+)?(?:,~?[\w\-]+(?:=[ ^,\s]+)?)*)?$/; | 93 Filter.regexpRegExp = /^(@@)?\/.*\/(?:\$~?[\w\-]+(?:=[^,\s]+)?(?:,~?[\w\-]+(?:=[ ^,\s]+)?)*)?$/; |
94 /** | 94 /** |
95 * Regular expression that options on a RegExp filter should match | 95 * Regular expression that options on a RegExp filter should match |
96 * @type RegExp | 96 * @type RegExp |
97 */ | 97 */ |
98 Filter.optionsRegExp = /\$(~?[\w\-]+(?:=[^,\s]+)?(?:,~?[\w\-]+(?:=[^,\s]+)?)*)$/ ; | 98 Filter.optionsRegExp = /\$(~?[\w\-]+(?:=[^,\s]+)?(?:,~?[\w\-]+(?:=[^,\s]+)?)*)$/ ; |
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
819 * @param {String} selector CSS selector for the HTML elements that should be hidden | 819 * @param {String} selector CSS selector for the HTML elements that should be hidden |
820 * @constructor | 820 * @constructor |
821 * @augments ActiveFilter | 821 * @augments ActiveFilter |
822 */ | 822 */ |
823 function ElemHideBase(text, domains, selector) | 823 function ElemHideBase(text, domains, selector) |
824 { | 824 { |
825 ActiveFilter.call(this, text, domains || null); | 825 ActiveFilter.call(this, text, domains || null); |
826 | 826 |
827 if (domains) | 827 if (domains) |
828 this.selectorDomain = domains.replace(/,~[^,]+/g, "").replace(/^~[^,]+,?/, " ").toLowerCase(); | 828 this.selectorDomain = domains.replace(/,~[^,]+/g, "").replace(/^~[^,]+,?/, " ").toLowerCase(); |
829 this.selector = selector; | 829 |
830 // Braces are being escaped to prevent CSS rule injection. | |
831 this.selector = selector.replace("{", "\\x7B").replace("}", "\\x7D"); | |
Wladimir Palant
2016/12/13 14:32:16
I was probably not clear enough but the space at t
Felix Dahlke
2016/12/13 16:04:48
Done. I gotta admit this is feeling hacky. But I t
Wladimir Palant
2016/12/13 16:29:12
This is exactly how EHH is doing it - took a while
| |
830 } | 832 } |
831 exports.ElemHideBase = ElemHideBase; | 833 exports.ElemHideBase = ElemHideBase; |
832 | 834 |
833 ElemHideBase.prototype = extend(ActiveFilter, { | 835 ElemHideBase.prototype = extend(ActiveFilter, { |
834 /** | 836 /** |
835 * @see ActiveFilter.domainSeparator | 837 * @see ActiveFilter.domainSeparator |
836 */ | 838 */ |
837 domainSeparator: ",", | 839 domainSeparator: ",", |
838 | 840 |
839 /** | 841 /** |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
971 */ | 973 */ |
972 function ElemHideEmulationFilter(text, domains, selector) | 974 function ElemHideEmulationFilter(text, domains, selector) |
973 { | 975 { |
974 ElemHideBase.call(this, text, domains, selector); | 976 ElemHideBase.call(this, text, domains, selector); |
975 } | 977 } |
976 exports.ElemHideEmulationFilter = ElemHideEmulationFilter; | 978 exports.ElemHideEmulationFilter = ElemHideEmulationFilter; |
977 | 979 |
978 ElemHideEmulationFilter.prototype = extend(ElemHideBase, { | 980 ElemHideEmulationFilter.prototype = extend(ElemHideBase, { |
979 type: "elemhideemulation" | 981 type: "elemhideemulation" |
980 }); | 982 }); |
OLD | NEW |