AdguardTeam / AdguardTeam/Scriptlets

Improve 'trusted-set-cookie' and 'trusted-set-local-storage-item' — add ability to specify base64 as encoding

Abierto
#307 4 comentarios 0 reacciones 1 asignado Asignado a @maximtop Ver en GitHub
enhancement Priority: P4
Lenguaje dominante
JavaScript
Estrellas
195
Forks
33
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

### _Steps to reproduce_

1. Add this user rule:
```adblock
@@||www.coolblue.be^$important,document
```
2. Go to https://www.coolblue.be/en and [refuse cookies](https://user-images.githubusercontent.com/4764956/230755586-3b52a7e8-4529-402c-b671-b8ce3df5a483.png).
3. Observe the apparition of a new _**cookie-preferences**_ cookie with this value:
```
eyJmdW5jdGlvbmFsIjp0cnVlLCJhbmFseXRpY2FsIjp0cnVlLCJtYXJrZXRpbmciOmZhbHNlfQ%3D%3D
```

### _Goal_

Replacing this rule _(comment included)_:  **#ᴄʀʏᴘᴛɪᴄ**
```adblock
! Base64 value for: {"functional":true,"analytical":true,"marketing":false}
coolblue.be#%#//scriptlet('trusted-set-cookie', 'cookie-preferences',
'eyJmdW5jdGlvbmFsIjp0cnVlLCJhbmFseXRpY2FsIjp0cnVlLCJtYXJrZXRpbmciOmZhbHNlfQ==')
```

By this one _(self-explanatory for readers)_:  **#ᴛʀᴀɴꜱᴘᴀʀᴇɴᴛ**
```adblock
coolblue.be#%#//scriptlet('trusted-set-cookie', 'cookie-preferences',
'base64:{"functional":true,"analytical":true,"marketing":false}')
```
 
### _:writing_hand: Remarks_

1. Possibly use a dedicated parameter instead.

2. ~~Consider in addition a _variant_ that does not use [`encodeURIComponent`](https://github.com/AdguardTeam/Scriptlets/blob/8edd4ec246a3acac608d67975610de11f9b0d960/src/helpers/cookie-utils.js#L37) for storing **base64** value,
for some websites reading the string _directly_ in `atob`.~~
~~- That is, the stored value will therefore include `==` instead of `%3D%3D` at the end.~~

↪️ Variant not anymore required. All situations will be handled correctly if this commit is finally merged:
[get rid of encodeURIComponent for trusted-set-cookie-* scriptlets](https://github.com/AdguardTeam/Scriptlets/commit/d03e0284d61ecc8c425c2443902c6a8d54c17fd6).
_As raw/pure base64 value generated by AdGuard will always be readable by the website:
whether the latter uses for reading atob, atob+decodeURIComponent, etc._

3. Should also apply to:
- the similar one `trusted-set-cookie-reload`;
- and, ideally, `trusted-set-local-storage-item` too.

 
### Hi and thanks in advance! :v:

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.