-
Notifications
You must be signed in to change notification settings - Fork 321
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
Add $cookie modifier support #961
Comments
These two issues might change the way we're going to implement this: |
@atropnikov see the last comment here:
|
In order to test turn off all filters // test cookie removal by the domain name and cookie name // test all cookie removal by a domain name // test cookie removal by regexp all cookies removals or their modifying should be visible in the filtering log also, check that in the integration mode cookies are not modified at all |
Merge in EXTENSIONS/browser-extension from feature/AG-8778 to feature/AG-2737 * commit '87f08fe6234fc33357089942134fb3ab586119bb': feature:AG-8778 validate settings json feature:AG-8778 validate settings json feature:AG-8778 validate settings json
Why:
I'd like this modifier to be able to:
Specification
The
$cookie
modifier completely changes rule behavior. Instead of blocking a request, this modifier makes us suppress or modify theCookie
andSet-Cookie
headers.$cookie
syntaxThe rule syntax depends on whether we are going to block all cookies or to remove a single cookie. The rule behavior can be changed with
maxAge
andsameSite
modifiers.||example.org^$cookie=NAME;maxAge=3600;sameSite=lax
-- every time AdGuard encounters a cookie calledNAME
in a request toexample.org
, it will do the following:3600
seconds||example.org^$cookie
-- blocks ALL cookies set byexample.org
. This is an equivalent to settingmaxAge
to zero.||example.org^$cookie=NAME
-- blocks a single cookie namedNAME
||example.org^$cookie=/regular_expression/
-- blocks every cookie that matches a given regular expression$cookie
rules are not affected by regular exception rules (@@
) unless it's a$document
exception. In order to disable a$cookie
rule, the exception rule should also have a$cookie
modifier. Here's how it works:@@||example.org^$cookie
-- unblocks all cookies set byexample.org
@@||example.org^$cookie=NAME
-- unblocks a single cookie namedNAME
@@||example.org^$cookie=/regular_expression/
-- unblocks every cookie matching a given regular expressionImplementation details
I suppose it is enough to intercept
Cookie
/Set-Cookie
headers and there's no need to mess with thedocument.cookie
property.Let's look at an example.
||example.org^$cookie=i_track_u
should block thei_track_u
cookie coming fromexample.org
https://example.org/count
Cookie
header value isi_track_u=1; JSESSIONID=321321
Cookie
header so that the server doesn't receive thei_track_u
value. Modified value:JSESSIONID=321321
Set-Cookie
headers received from the server.i_track_u
cookie (or modify it and strip that cookie if it contains more than one)Set-Cookie
header that setsi_track_u
with a negative expiration date:Set-Cookie: i_track_u=1; expires=[CURRENT_DATETIME]; path=/; domain=.example.org
.Real-life examples
$cookie=__cfduid
-- blocks CloudFlare cookie everywhere$cookie=/__utm[a-z]/
-- blocks Google Analytics cookies everywhere||facebook.com^$third-party,cookie=c_user
-- prevents Facebook from tracking you even if you are logged inThe text was updated successfully, but these errors were encountered: