From decafc5cbfdc38935ced008c87c63a70feb3ae5c Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Sun, 12 Nov 2023 19:05:56 -0500 Subject: [PATCH] Allow the use of quotes in `set-[local|session]-storage-item` Related discussion: https://github.com/uBlockOrigin/uAssets/issues/20630#issuecomment-1807260357 --- assets/resources/scriptlets.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/assets/resources/scriptlets.js b/assets/resources/scriptlets.js index 2f3d7e2bd..d6a2d2d5e 100644 --- a/assets/resources/scriptlets.js +++ b/assets/resources/scriptlets.js @@ -848,10 +848,13 @@ function setLocalStorageItemFn( value = (new Date()).toISOString(); } } else { - if ( trustedValues.includes(value.toLowerCase()) === false ) { - if ( /^\d+$/.test(value) === false ) { return; } - value = parseInt(value, 10); - if ( value > 32767 ) { return; } + const normalized = value.toLowerCase(); + const match = /^("?)(.+)\1$/.exec(normalized); + const unquoted = match && match[2] || normalized; + if ( trustedValues.includes(unquoted) === false ) { + if ( /^\d+$/.test(unquoted) === false ) { return; } + const integer = parseInt(unquoted, 10); + if ( integer > 32767 ) { return; } } }