-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
script:inject with only negated domains cause cosmetic filtering engine to crash #3375
Comments
I have been refactoring scriptlet injection (#3069), and I currently can't reproduce this specific error with the new code, but then I am reminded I need to handle the negated hostname case for filters which are not allowed to apply everywhere. |
That's not quite right, the Firefox swallows lots of errors, so when you insert invalid CSS, on Firefox it will just silently fail. This is the same for many other ( |
I said I refactored -- how would you know how the not-yet-committed refactored code looks like to be able to make a "not quite right" observation? Scriptlet injection is no longer handled by |
Fixed with a9f68fe. |
Describe the issue
When a
script:inject
filter has only negated domains, cosmetic filter parser does not properly discard it.One or more specific URLs where the issue occurs
http://example.com/
Screenshot in which the issue can be seen
Steps for anyone to reproduce the issue
~example.com##script:inject(abort-on-proerty-read.js, test)
toMy filters
http://example.com/
and open the consoleYour settings
All default
Your filter lists
All default
Your custom filters (if any)
See steps to reproduce
Additional details
Although the crash is caused by an invalid filter, uBO is suppose to discard bad filters.
At around line 365 of
cosmetic-filtering.js
:This is the logic which mark expensive filters as invalid if they are generic. However, it does not handle the case where all domains are negated.
Later, at around line 1175 of
cosmetic-filtering.js
:When there are only negated domains,
applyGlobally
will be true and it will useFilterContainer.prototype.compileGenericSelector
to compile the filter, which does not expect expensive filters. The compiled data is invalid / corrupted which later cause error in cosmetic filtering engine.Inside
FilterContainer.prototype.compileGenericHideSelector
, I see the comment:I'm not sure if you have plan on adding logic to handle it there, but for scriptlet injection, execution won't reach that point (the place where the comment is).
I think the filter should be re-checked for validity inside the if-statement for
applyGlobally
.The text was updated successfully, but these errors were encountered: