Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: lib/filterClasses.js

Issue 29367031: Issue 4684 - Allow { and } in attribute and property selectors (Closed) Base URL: https://bitbucket.org/fhd/adblockpluscore
Left Patch Set: Created Dec. 8, 2016, 10:10 a.m.
Right Patch Set: Add a space after the escape sequence for { and } Created Dec. 13, 2016, 4:01 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « chrome/content/elemHideEmulation.js ('k') | test/filterClasses.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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
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\-]+(?: [$^*]?=[^\(\)"]*)?\))*)|#((?:[^{}]|(?:\[[\w-]+[~|]?=(['"])[^'"]*?\6\]))+))$/; 88 Filter.elemhideRegExp = /^([^\/\*\|\@"!]*?)#(\@)?(?:([\w\-]+|\*)((?:\([\w\-]+(?: [$^*]?=[^\(\)"]*)?\))*)|#(.+))$/;
Wladimir Palant 2016/12/08 12:36:19 This won't consider escaped quotation marks proper
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
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 ");
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
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 });
LEFTRIGHT

Powered by Google App Engine
This is Rietveld