abp-filter-parser icon indicating copy to clipboard operation
abp-filter-parser copied to clipboard

Fix bad regex check

Open freehuntx opened this issue 7 years ago • 2 comments

Using indexOf will break, if a regex contains $. lastIndexOf will solve the problem.

freehuntx avatar Dec 22 '17 05:12 freehuntx

Hello @bbondy, what about this fix? Latest easylist contains such regular expressions.

Deliaz avatar Jan 12 '18 09:01 Deliaz

This does not fix the problem (or rather creates a new one). Consider this:

"||optimizely.com^$third-party".indexOf('$',0)//17
"||optimizely.com^$third-party".lastIndexOf('$', 0);//-1

Second parameter is to blame here. It works differently for indexOf and lastIndexOf.


We have 3 cases here:

  • /\.cricket\/[0-9]{2,9}\/$/$script,stylesheet,third-party,xmlhttprequest - regex $ + options
  • /$file/analytics. - regex $, no options
  • &refer=http$script - no regex, options

kdzwinel avatar Feb 28 '18 21:02 kdzwinel