From 0e1e4b82c5ea464f1e7837c5c8f400e5ffac4b3c Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Tue, 28 May 2024 09:18:09 -0400 Subject: [PATCH] Improve `trusted-set-cookie` scriptlet Replace placehoders instead of direct assignement Related feedback: https://github.com/uBlockOrigin/uAssets/pull/23877#issuecomment-2134417389 --- assets/resources/scriptlets.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/assets/resources/scriptlets.js b/assets/resources/scriptlets.js index 051b6e218..1ba460c2e 100644 --- a/assets/resources/scriptlets.js +++ b/assets/resources/scriptlets.js @@ -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 = '';