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

Side by Side Diff: lib/filterClasses.js

Issue 29849575: Issue 6797 - Require active domains in snippet filters (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Use different snippets names Created Aug. 8, 2018, 1:55 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | test/snippets.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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-present eyeo GmbH 3 * Copyright (C) 2006-present 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 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after
1060 { 1060 {
1061 // We don't allow content filters which have any empty domains. 1061 // We don't allow content filters which have any empty domains.
1062 // Note: The ContentFilter.prototype.domainSeparator is duplicated here, if 1062 // Note: The ContentFilter.prototype.domainSeparator is duplicated here, if
1063 // that changes this must be changed too. 1063 // that changes this must be changed too.
1064 if (domains && /(^|,)~?(,|$)/.test(domains)) 1064 if (domains && /(^|,)~?(,|$)/.test(domains))
1065 return new InvalidFilter(text, "filter_invalid_domain"); 1065 return new InvalidFilter(text, "filter_invalid_domain");
1066 1066
1067 if (type == "@") 1067 if (type == "@")
1068 return new ElemHideException(text, domains, body); 1068 return new ElemHideException(text, domains, body);
1069 1069
1070 if (type == "$") 1070 if (type == "?" || type == "$")
1071 {
1072 // Element hiding emulation and snippet filters are inefficient so we need
1073 // to make sure that they're only applied if they specify active domains
1074 if (!/,[^~][^,.]*\.[^,]/.test("," + domains))
1075 {
1076 return new InvalidFilter(text, type == "?" ?
1077 "filter_elemhideemulation_nodomain" :
1078 "filter_snippet_nodomain");
1079 }
1080
1081 if (type == "?")
1082 return new ElemHideEmulationFilter(text, domains, body);
1083
1071 return new SnippetFilter(text, domains, body); 1084 return new SnippetFilter(text, domains, body);
1072
1073 if (type == "?")
1074 {
1075 // Element hiding emulation filters are inefficient so we need to make sure
1076 // that they're only applied if they specify active domains
1077 if (!/,[^~][^,.]*\.[^,]/.test("," + domains))
1078 return new InvalidFilter(text, "filter_elemhideemulation_nodomain");
1079
1080 return new ElemHideEmulationFilter(text, domains, body);
1081 } 1085 }
1082 1086
1083 return new ElemHideFilter(text, domains, body); 1087 return new ElemHideFilter(text, domains, body);
1084 }; 1088 };
1085 1089
1086 /** 1090 /**
1087 * Base class for element hiding filters 1091 * Base class for element hiding filters
1088 * @param {string} text see {@link Filter Filter()} 1092 * @param {string} text see {@link Filter Filter()}
1089 * @param {string} [domains] see {@link ContentFilter ContentFilter()} 1093 * @param {string} [domains] see {@link ContentFilter ContentFilter()}
1090 * @param {string} selector CSS selector for the HTML elements that should be 1094 * @param {string} selector CSS selector for the HTML elements that should be
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1183 1187
1184 /** 1188 /**
1185 * Script that should be executed 1189 * Script that should be executed
1186 * @type {string} 1190 * @type {string}
1187 */ 1191 */
1188 get script() 1192 get script()
1189 { 1193 {
1190 return this.body; 1194 return this.body;
1191 } 1195 }
1192 }); 1196 });
OLDNEW
« no previous file with comments | « no previous file | test/snippets.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld