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

Unified Diff: lib/filterClasses.js

Issue 29746563: Noissue - Trim spaces around element hiding emulation selectors (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Update elemhideRegExp Created April 11, 2018, 11:44 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 | test/filterClasses.js » ('j') | 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
@@ -82,17 +82,17 @@
* @type {Map.<string,Filter>}
*/
Filter.knownFilters = new Map();
/**
* Regular expression that element hiding filters should match
* @type {RegExp}
*/
-Filter.elemhideRegExp = /^([^/*|@"!]*?)#([@?])?#(.+)$/;
+Filter.elemhideRegExp = /^([^/*|@"!?]*?)#([@?])?#(.+)$/;
/**
* Regular expression that RegExp filters specified as RegExps should match
* @type {RegExp}
*/
Filter.regexpRegExp = /^(@@)?\/.*\/(?:\$~?[\w-]+(?:=[^,\s]+)?(?:,~?[\w-]+(?:=[^,\s]+)?)*)?$/;
/**
* Regular expression that options on a RegExp filter should match
* @type {RegExp}
@@ -183,17 +183,17 @@
// Don't remove spaces inside comments
if (/^ *!/.test(text))
return text.trim();
// Special treatment for element hiding filters, right side is allowed to
// contain spaces
if (Filter.elemhideRegExp.test(text))
{
- let [, domain, separator, selector] = /^(.*?)(#@?#?)(.*)$/.exec(text);
+ let [, domain, separator, selector] = /^(.*?)(#[@?]?#?)(.*)$/.exec(text);
return domain.replace(/ +/g, "") + separator + selector.trim();
}
// For most regexp filters we strip all spaces, but $csp filter options
// are allowed to contain single (non trailing) spaces.
let strippedText = text.replace(/ +/g, "");
if (!strippedText.includes("$") || !/\bcsp=/i.test(strippedText))
return strippedText;
« no previous file with comments | « no previous file | test/filterClasses.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld