Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix 'trusted-set-cookie-reload' — website is not reloaded if '$now$' value is used #291

Closed
AdamWr opened this issue Feb 25, 2023 · 0 comments

Comments

@AdamWr
Copy link
Member

AdamWr commented Feb 25, 2023

It seems that website is not reloaded if rule like this:

example.org#%#//scriptlet('trusted-set-cookie-reload', 'cmpconsent', '$now$')

is used.

Probably the problem is with value === cookieValue here:

export const isCookieSetWithValue = (cookieString, name, value) => {
return cookieString.split(';')
.some((cookieStr) => {
const pos = cookieStr.indexOf('=');
if (pos === -1) {
return false;
}
const cookieName = cookieStr.slice(0, pos).trim();
const cookieValue = cookieStr.slice(pos + 1).trim();
return name === cookieName && value === cookieValue;
});
};

The value is $now$, but cookieValue is created by Date.now().toString(), so it's something like 1677324255603 and function returns false.

@adguard-bot adguard-bot changed the title trusted-set-cookie-reload doesn't reload website if $now$ value is used Fix 'trusted-set-cookie-reload' — website is not reloaded if '$now$' value is used Feb 27, 2023
@slavaleleka slavaleleka added the bug Something isn't working label Mar 22, 2023
adguard pushed a commit that referenced this issue Apr 28, 2023
… '$now$' value is used. #291

Squashed commit of the following:

commit 67987c5
Author: Slava Leleka <v.leleka@adguard.com>
Date:   Fri Apr 28 17:21:53 2023 +0300

    fix changelog link

commit c9679ed
Author: Adam Wróblewski <adam@adguard.com>
Date:   Fri Apr 28 16:10:29 2023 +0200

    Remove unnecessary tests
    Use toBeTruthy() instead of toBe(true) in tests
    Add better comment about path in clearCookie function
    Move fix to unreleased section in changelog

commit 91abfd2
Author: Adam Wróblewski <adam@adguard.com>
Date:   Fri Apr 28 15:05:31 2023 +0200

    Add information about jest to readme
    Mock console.trace to fix errors in jest tests

commit c5c53db
Author: Maxim Topciu <mtopciu@adguard.com>
Date:   Fri Apr 28 15:34:54 2023 +0300

    AG-20095 rename test to spec

commit c39dbc2
Author: Maxim Topciu <mtopciu@adguard.com>
Date:   Fri Apr 28 14:14:24 2023 +0300

    Add yarn test to package.json

commit ecc65f6
Merge: 085a374 402972c
Author: Adam Wróblewski <adam@adguard.com>
Date:   Fri Apr 28 13:13:22 2023 +0200

    Merge branch 'master' into fix/AG-20095

commit 085a374
Author: Adam Wróblewski <adam@adguard.com>
Date:   Thu Apr 27 20:37:50 2023 +0200

    Use jest test for trusted-set-cookie-reload
    Use better approach to check cookie

commit 6ac14db
Author: Adam Wróblewski <adam@adguard.com>
Date:   Mon Apr 3 12:01:23 2023 +0200

    Fix 'trusted-set-cookie-reload' — website is not reloaded if '$now$' value is used
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

4 participants