-
Notifications
You must be signed in to change notification settings - Fork 101
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: implement $replace
modifier, improve option parsing
#3897
Conversation
$replace
modifier
Note: |
|
@seia-soto Could you share more information on the
Thanks, I think it will help review the implementation. |
@remusao In aspect of adblocker library, the importance of |
All uBO filters
|
Just a note: better filter selection should be done from |
Current matching logic in Ghostery 10 for Firefox: will have to changed from:
to:
|
2a03145
to
da5f5b9
Compare
Note: This PR requires additional updates coming from: seia-soto#3 |
2d34e34
to
18bd35b
Compare
$replace
modifier$replace
modifier, improve option parsing
This also requires a performance improvement.
Ratio offset from initialisation time:
*sha:dc9d1b6a0711c22464c6e3006338165cc26d4ba2 |
eadf7fb
to
be245e8
Compare
- Simpler check on output chunks of StreamFilterMock - Improve readability on tests Co-authored-by: philipp <philipp@ghostery.com> Co-authored-by: chrmod <chrmod@ghostery.com>
type CosmeticFilterMatchingContext = | ||
| { | ||
url: string; | ||
callerContext: any; // Additional context given from user | ||
filterType: FilterType.COSMETIC; | ||
} | ||
| { | ||
request: Request; // For HTML Filters | ||
filterType: FilterType.COSMETIC; | ||
}; |
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.
Should we have an attribute which can be used to discriminate (as in "tagged union") which of the two options this is when manipulating a value? Or do we want to implicitly discriminate based on presence of url
, etc.
type CosmeticFilterMatchingContext = | |
| { | |
url: string; | |
callerContext: any; // Additional context given from user | |
filterType: FilterType.COSMETIC; | |
} | |
| { | |
request: Request; // For HTML Filters | |
filterType: FilterType.COSMETIC; | |
}; | |
type CosmeticFilterMatchingContext = | |
| { | |
type: 'elementHiding', | |
url: string; | |
callerContext: any; // Additional context given from user | |
filterType: FilterType.COSMETIC; | |
} | |
| { | |
type: 'htmlFiltering', | |
request: Request; // For HTML Filters | |
filterType: FilterType.COSMETIC; | |
}; |
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.
honestly I don't know yet - I'm fine to keep it as is
Co-authored-by: Rémi <remusao@users.noreply.github.com>
Latest firefox automatically lowers all header names. ``` import Fastify from 'fastify' const fastify = Fastify({ logger: true }) // Declare a route fastify.get('/', async function handler(request, reply) { reply.header('UPPERCASED', '1') return { hello: 'world' } }) // Run the server! try { await fastify.listen({ port: 3000 }) } catch (err) { fastify.log.error(err) process.exit(1) } ```
feat: perform html filtering on headers received
Co-authored-by: Rémi <remusao@users.noreply.github.com>
Co-authored-by: Philipp Claßen <philipp.classen@posteo.de>
Co-authored-by: Philipp Claßen <philipp.classen@posteo.de>
Co-authored-by: Philipp Claßen <philipp.classen@posteo.de>
Co-authored-by: Philipp Claßen <philipp.classen@posteo.de>
Co-authored-by: Rémi <remusao@users.noreply.github.com>
fixes #3886 built top on #3887
https://adguard.com/kb/general/ad-filtering/create-own-filters/#replace-modifier
Following Adguard spec:
$replace
rules apply to any text response, but will not apply to binary (media
,image,
object`, etc). (feat: perform html filtering on headers received seia-soto/adblocker#14)$replace
rules do not apply if the size of the original response is more than 10 MB (feat: perform html filtering on headers received seia-soto/adblocker#14)$replace
rules have a higher priority than other basic rules (including exception rules). So if a request corresponds to two different rules one of which has the $replace modifier, this rule will be applied.