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

Side by Side Diff: lib/filterClasses.js

Issue 29464708: Issue 5314 - Allow hide emulation filters to be with a plain selector (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created June 14, 2017, 3:18 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
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-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 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 950 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 if (type == "@") 961 if (type == "@")
962 return new ElemHideException(text, domain, selector); 962 return new ElemHideException(text, domain, selector);
963 963
964 if (type == "?") 964 if (type == "?")
965 { 965 {
966 // Element hiding emulation filters are inefficient so we need to make sure 966 // Element hiding emulation filters are inefficient so we need to make sure
967 // that they're only applied if they specify active domains 967 // that they're only applied if they specify active domains
968 if (!/,[^~][^,.]*\.[^,]/.test("," + domain)) 968 if (!/,[^~][^,.]*\.[^,]/.test("," + domain))
969 return new InvalidFilter(text, "filter_elemhideemulation_nodomain"); 969 return new InvalidFilter(text, "filter_elemhideemulation_nodomain");
970 970
971 // The selector should contain at least one :-abp-foo() pseudo-class
972 if (!/:-abp-[\w-]+\(/.test(selector))
973 return new InvalidFilter(text, "filter_elemhideemulation_plainselector");
974
975 return new ElemHideEmulationFilter(text, domain, selector); 971 return new ElemHideEmulationFilter(text, domain, selector);
976 } 972 }
977 973
978 return new ElemHideFilter(text, domain, selector); 974 return new ElemHideFilter(text, domain, selector);
979 }; 975 };
980 976
981 /** 977 /**
982 * Class for element hiding filters 978 * Class for element hiding filters
983 * @param {string} text see Filter() 979 * @param {string} text see Filter()
984 * @param {string} domains see ElemHideBase() 980 * @param {string} domains see ElemHideBase()
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 */ 1020 */
1025 function ElemHideEmulationFilter(text, domains, selector) 1021 function ElemHideEmulationFilter(text, domains, selector)
1026 { 1022 {
1027 ElemHideBase.call(this, text, domains, selector); 1023 ElemHideBase.call(this, text, domains, selector);
1028 } 1024 }
1029 exports.ElemHideEmulationFilter = ElemHideEmulationFilter; 1025 exports.ElemHideEmulationFilter = ElemHideEmulationFilter;
1030 1026
1031 ElemHideEmulationFilter.prototype = extend(ElemHideBase, { 1027 ElemHideEmulationFilter.prototype = extend(ElemHideBase, {
1032 type: "elemhideemulation" 1028 type: "elemhideemulation"
1033 }); 1029 });
OLDNEW

Powered by Google App Engine
This is Rietveld