1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-07-05 11:37:01 +02:00

Allow the use of quotes in set-[local|session]-storage-item

Related discussion:
https://github.com/uBlockOrigin/uAssets/issues/20630#issuecomment-1807260357
This commit is contained in:
Raymond Hill 2023-11-12 19:05:56 -05:00
parent b26d421a57
commit decafc5cbf
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -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; }
}
}