mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-22 18:32:45 +01:00
Minor code review of set-local-storage-item
scriptlet
This commit is contained in:
parent
e50b391105
commit
ea4afc0610
@ -2788,25 +2788,15 @@ function setLocalStorageItem(
|
||||
if ( key === '' ) { return; }
|
||||
if ( value === '' ) { return; }
|
||||
|
||||
const validValues = [
|
||||
'undefined', 'null',
|
||||
'false', 'true',
|
||||
'yes', 'no',
|
||||
'{}', '[]', "''",
|
||||
];
|
||||
let actualValue;
|
||||
if ( value === 'undefined' ) {
|
||||
actualValue = undefined;
|
||||
} else if ( value === 'false' ) {
|
||||
actualValue = false;
|
||||
} else if ( value === 'true' ) {
|
||||
actualValue = true;
|
||||
} else if ( value === 'null' ) {
|
||||
actualValue = null;
|
||||
} else if ( value === '{}' ) {
|
||||
actualValue = '{}';
|
||||
} else if ( value === '[]' ) {
|
||||
actualValue = '[]';
|
||||
} else if ( value === "''" ) {
|
||||
actualValue = '';
|
||||
} else if ( value === 'yes' ) {
|
||||
actualValue = 'yes';
|
||||
} else if ( value === 'no' ) {
|
||||
actualValue = 'no';
|
||||
if ( validValues.includes(value) ) {
|
||||
actualValue = value;
|
||||
} else if ( /^\d+$/.test(value) ) {
|
||||
actualValue = parseInt(value, 10);
|
||||
if ( actualValue > 32767 ) { return; }
|
||||
|
Loading…
Reference in New Issue
Block a user