Bug in Matcher.findKeyword?
Posted: Thu Feb 25, 2016 4:13 pm
Hello, I'm having some troubles adding a new filter to my subscription file. When I add the line "agentguru.ru$third-party" (without quotes) it doesn't work as expected — scripts from the domain agentguru.ru are not blocked.
After digging into code, I found this line in Matcher.findKeyword():
(https://hg.adblockplus.org/adblockplusc ... er.js#l125)
The regular expression looks wrong: asterisks are probably meant to be outside of square brackets, like /[^a-z0-9%]*[a-z0-9%]{3,}(?=[^a-z0-9%]*)/g. In its current form this expression fails to capture any keywords from url unless it starts with a special character.
When I fix this part of code (in Chrome DevTools), AdBlock starts working correctly, blocking scripts from the domain mentioned above.
After digging into code, I found this line in Matcher.findKeyword():
Code: Select all
let candidates = text.toLowerCase().match(/[^a-z0-9%*][a-z0-9%]{3,}(?=[^a-z0-9%*])/g);
The regular expression looks wrong: asterisks are probably meant to be outside of square brackets, like /[^a-z0-9%]*[a-z0-9%]{3,}(?=[^a-z0-9%]*)/g. In its current form this expression fails to capture any keywords from url unless it starts with a special character.
When I fix this part of code (in Chrome DevTools), AdBlock starts working correctly, blocking scripts from the domain mentioned above.