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

Delta Between Two Patch Sets: lib/filterClasses.js

Issue 29757595: Noissue - Use plural for element hiding domains (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Created April 20, 2018, 8:22 p.m.
Right Patch Set: Rebase Created May 2, 2018, 1:34 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 | « no previous file | 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-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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 text = text.replace(/[^\S ]+/g, ""); 181 text = text.replace(/[^\S ]+/g, "");
182 182
183 // Don't remove spaces inside comments 183 // Don't remove spaces inside comments
184 if (/^ *!/.test(text)) 184 if (/^ *!/.test(text))
185 return text.trim(); 185 return text.trim();
186 186
187 // Special treatment for element hiding filters, right side is allowed to 187 // Special treatment for element hiding filters, right side is allowed to
188 // contain spaces 188 // contain spaces
189 if (Filter.elemhideRegExp.test(text)) 189 if (Filter.elemhideRegExp.test(text))
190 { 190 {
191 let [, domains, separator, selector] = /^(.*?)(#@?#?)(.*)$/.exec(text); 191 let [, domains, separator, selector] = /^(.*?)(#[@?]?#?)(.*)$/.exec(text);
192 return domains.replace(/ +/g, "") + separator + selector.trim(); 192 return domains.replace(/ +/g, "") + separator + selector.trim();
193 } 193 }
194 194
195 // For most regexp filters we strip all spaces, but $csp filter options 195 // For most regexp filters we strip all spaces, but $csp filter options
196 // are allowed to contain single (non trailing) spaces. 196 // are allowed to contain single (non trailing) spaces.
197 let strippedText = text.replace(/ +/g, ""); 197 let strippedText = text.replace(/ +/g, "");
198 if (!strippedText.includes("$") || !/\bcsp=/i.test(strippedText)) 198 if (!strippedText.includes("$") || !/\bcsp=/i.test(strippedText))
199 return strippedText; 199 return strippedText;
200 200
201 let optionsMatch = Filter.optionsRegExp.exec(strippedText); 201 let optionsMatch = Filter.optionsRegExp.exec(strippedText);
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 value = option.substr(separatorIndex + 1); 786 value = option.substr(separatorIndex + 1);
787 option = option.substr(0, separatorIndex); 787 option = option.substr(0, separatorIndex);
788 } 788 }
789 option = option.replace(/-/, "_").toUpperCase(); 789 option = option.replace(/-/, "_").toUpperCase();
790 if (option in RegExpFilter.typeMap) 790 if (option in RegExpFilter.typeMap)
791 { 791 {
792 if (contentType == null) 792 if (contentType == null)
793 contentType = 0; 793 contentType = 0;
794 contentType |= RegExpFilter.typeMap[option]; 794 contentType |= RegExpFilter.typeMap[option];
795 795
796 if (option == "CSP" && typeof value != "undefined") 796 if (option == "CSP" && value)
797 csp = value; 797 csp = value;
798 } 798 }
799 else if (option[0] == "~" && option.substr(1) in RegExpFilter.typeMap) 799 else if (option[0] == "~" && option.substr(1) in RegExpFilter.typeMap)
800 { 800 {
801 if (contentType == null) 801 if (contentType == null)
802 ({contentType} = RegExpFilter.prototype); 802 ({contentType} = RegExpFilter.prototype);
803 contentType &= ~RegExpFilter.typeMap[option.substr(1)]; 803 contentType &= ~RegExpFilter.typeMap[option.substr(1)];
804 } 804 }
805 else if (option == "MATCH_CASE") 805 else if (option == "MATCH_CASE")
806 matchCase = true; 806 matchCase = true;
807 else if (option == "~MATCH_CASE") 807 else if (option == "~MATCH_CASE")
808 matchCase = false; 808 matchCase = false;
809 else if (option == "DOMAIN" && typeof value != "undefined") 809 else if (option == "DOMAIN" && value)
810 domains = value.toUpperCase(); 810 domains = value.toUpperCase();
811 else if (option == "THIRD_PARTY") 811 else if (option == "THIRD_PARTY")
812 thirdParty = true; 812 thirdParty = true;
813 else if (option == "~THIRD_PARTY") 813 else if (option == "~THIRD_PARTY")
814 thirdParty = false; 814 thirdParty = false;
815 else if (option == "COLLAPSE") 815 else if (option == "COLLAPSE")
816 collapse = true; 816 collapse = true;
817 else if (option == "~COLLAPSE") 817 else if (option == "~COLLAPSE")
818 collapse = false; 818 collapse = false;
819 else if (option == "SITEKEY" && typeof value != "undefined") 819 else if (option == "SITEKEY" && value)
820 sitekeys = value.toUpperCase(); 820 sitekeys = value.toUpperCase();
821 else 821 else
822 return new InvalidFilter(origText, "filter_unknown_option"); 822 return new InvalidFilter(origText, "filter_unknown_option");
823 } 823 }
824 } 824 }
825 825
826 try 826 try
827 { 827 {
828 if (blocking) 828 if (blocking)
829 { 829 {
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1080 */ 1080 */
1081 function ElemHideEmulationFilter(text, domains, selector) 1081 function ElemHideEmulationFilter(text, domains, selector)
1082 { 1082 {
1083 ElemHideBase.call(this, text, domains, selector); 1083 ElemHideBase.call(this, text, domains, selector);
1084 } 1084 }
1085 exports.ElemHideEmulationFilter = ElemHideEmulationFilter; 1085 exports.ElemHideEmulationFilter = ElemHideEmulationFilter;
1086 1086
1087 ElemHideEmulationFilter.prototype = extend(ElemHideBase, { 1087 ElemHideEmulationFilter.prototype = extend(ElemHideBase, {
1088 type: "elemhideemulation" 1088 type: "elemhideemulation"
1089 }); 1089 });
LEFTRIGHT

Powered by Google App Engine
This is Rietveld