-
Notifications
You must be signed in to change notification settings - Fork 104
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
feat: to
network modifier
#4524
base: master
Are you sure you want to change the base?
Conversation
to
network modifier
Despite we marked it's not safe to add one more bit before, but it's still safe to use 31st bit given that we're treating the number as unsigned integer. > const buf = new Uint8Array(4)
undefined
> buf.length
4
> buf[0] = (1 << 31) >>> 24
128
> buf
Uint8Array(4) [ 128, 0, 0, 0 ]
> (buf[0] << 24) >>> 0
2147483648 |
for (const part of value.split('|')) { | ||
if (option === 'to') { | ||
if (part.charCodeAt(0) === 126 /* '~' */) { | ||
denyallowEntities.add(part.slice(1)); | ||
} else { | ||
denyallowEntities.add(`~${part}`); | ||
} | ||
} else { | ||
denyallowEntities.add(part); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this would be best handled inside of Domains
directly. Maybe with a flag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The second argument of "Domain" is "debug = false". I don't know if it's still straightforward to have a third argument after this. There's no reason not to do that but need to find how to do that cleanly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding an argument is only one way to go about it that does not change the main comment. You can also use static method, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is duplicate of #4525 which is already being handled. I don't know which will be merged first but I believe we can put this off for a while.
This partially implements https://github.com/gorhill/uBlock/wiki/Static-filter-syntax#to.
In the documentation,
to
is described as:However, we already support entity-based syntax in
Domains
and only thing required is negation according to entity documentation: https://github.com/gorhill/uBlock/wiki/Static-filter-syntax#entityWe still don't support regular expression both in
domain
anddenyallow
options. Same goes forto
:*$to=~/regex.../
.denyallow
with uBo: ✅ negation and listing ❌ entities ❌ regexto
with uBo: ✅ negation and listing ✅ entities ✅ regexdenyallow
,to
with Ghostery: ✅ negation and listing ✅ entities ❌ regexThis PR negates all hostnames in parse-time to flip the behavior of
denyallow
whento
is detected.Also, rejects to parse filter having both
denyallow
andto
since both are not likely to be used together.We can merge multiple domains then make it work but then we'll require extra space that allows us to determine which hostname is for
to
anddenyallow
when runningtoString
.This PR also fixes
denyallow
domain list not being printed in a correct format fromtoString
method. There's a same regression intoString
regrading other network modifiers utilizingDomains
likefrom
and planned to fix in separate PR.