Skip to content

Commit

Permalink
Allow the use of quotes in set-[local|session]-storage-item
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Nov 13, 2023
1 parent b26d421 commit decafc5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions assets/resources/scriptlets.js
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
}

Expand Down

0 comments on commit decafc5

Please sign in to comment.