Skip to content

Commit

Permalink
Improve trusted-set-cookie scriptlet
Browse files Browse the repository at this point in the history
Replace placehoders instead of direct assignement

Related feedback:
uBlockOrigin/uAssets#23877 (comment)
  • Loading branch information
gorhill committed May 28, 2024
1 parent d8a77f3 commit 0e1e4b8
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions assets/resources/scriptlets.js
Original file line number Diff line number Diff line change
Expand Up @@ -4228,10 +4228,11 @@ function trustedSetCookie(
const logPrefix = safe.makeLogPrefix('set-cookie', name, value, path);
const time = new Date();

if ( value === '$now$' ) {
value = Date.now();
} else if ( value === '$currentDate$' ) {
value = time.toUTCString();
if ( value.includes('$now$') ) {
value = value.replaceAll('$now$', time.getTime());
}
if ( value.includes('$currentDate$') ) {
value = value.replaceAll('$currentDate$', time.toUTCString());
}

let expires = '';
Expand Down

0 comments on commit 0e1e4b8

Please sign in to comment.