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

Side by Side Diff: lib/filterClasses.js

Issue 29854584: Noissue - Use regular expression to parse filter options (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created Aug. 13, 2018, 2:42 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
« no previous file with comments | « no previous file | no next file » | 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 744 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 } 755 }
756 756
757 let contentType = null; 757 let contentType = null;
758 let matchCase = null; 758 let matchCase = null;
759 let domains = null; 759 let domains = null;
760 let sitekeys = null; 760 let sitekeys = null;
761 let thirdParty = null; 761 let thirdParty = null;
762 let collapse = null; 762 let collapse = null;
763 let csp = null; 763 let csp = null;
764 let rewrite = null; 764 let rewrite = null;
765 let options; 765
766 let match = text.includes("$") ? Filter.optionsRegExp.exec(text) : null; 766 let match = text.includes("$") ? Filter.optionsRegExp.exec(text) : null;
767 if (match) 767 if (match)
768 { 768 {
769 options = match[1].split(",");
770 text = match.input.substr(0, match.index); 769 text = match.input.substr(0, match.index);
771 for (let option of options) 770
771 for (let re = /([^,=]+)(?:=([^,]*))?/g, m; m = re.exec(match[1]);)
772 { 772 {
773 let value = null; 773 let [, option, value] = m;
774 let separatorIndex = option.indexOf("=");
775 if (separatorIndex >= 0)
776 {
777 value = option.substr(separatorIndex + 1);
778 option = option.substr(0, separatorIndex);
779 }
780 774
781 let inverse = option[0] == "~"; 775 let inverse = option[0] == "~";
782 if (inverse) 776 if (inverse)
783 option = option.substr(1); 777 option = option.substr(1);
784 778
785 let type = RegExpFilter.typeMap[option.replace(/-/, "_").toUpperCase()]; 779 let type = RegExpFilter.typeMap[option.replace(/-/, "_").toUpperCase()];
786 if (type) 780 if (type)
787 { 781 {
788 if (inverse) 782 if (inverse)
789 { 783 {
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 1181
1188 /** 1182 /**
1189 * Script that should be executed 1183 * Script that should be executed
1190 * @type {string} 1184 * @type {string}
1191 */ 1185 */
1192 get script() 1186 get script()
1193 { 1187 {
1194 return this.body; 1188 return this.body;
1195 } 1189 }
1196 }); 1190 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld