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

Unified 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.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/filterClasses.js
===================================================================
--- a/lib/filterClasses.js
+++ b/lib/filterClasses.js
@@ -757,31 +757,25 @@
let contentType = null;
let matchCase = null;
let domains = null;
let sitekeys = null;
let thirdParty = null;
let collapse = null;
let csp = null;
let rewrite = null;
- let options;
+
let match = text.includes("$") ? Filter.optionsRegExp.exec(text) : null;
if (match)
{
- options = match[1].split(",");
text = match.input.substr(0, match.index);
- for (let option of options)
+
+ for (let re = /([^,=]+)(?:=([^,]*))?/g, m; m = re.exec(match[1]);)
{
- let value = null;
- let separatorIndex = option.indexOf("=");
- if (separatorIndex >= 0)
- {
- value = option.substr(separatorIndex + 1);
- option = option.substr(0, separatorIndex);
- }
+ let [, option, value] = m;
let inverse = option[0] == "~";
if (inverse)
option = option.substr(1);
let type = RegExpFilter.typeMap[option.replace(/-/, "_").toUpperCase()];
if (type)
{
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld