Skip to content

Commit

Permalink
Eliminate case-sensitivity from values in set-cookie scriptlet
Browse files Browse the repository at this point in the history
Related discussion:
- uBlockOrigin/uAssets#18762 (reply in thread)

Additionally, add `allow` as valid value.
  • Loading branch information
gorhill committed Jul 20, 2023
1 parent 9d20cbe commit 03d0d8d
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions assets/resources/scriptlets.js
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ function setLocalStorageItemCore(
value = `${Date()}`;
}
} else {
if ( trustedValues.includes(value) === false ) {
if ( trustedValues.includes(value.toLowerCase()) === false ) {
if ( /^\d+$/.test(value) === false ) { return; }
value = parseInt(value, 10);
if ( value > 32767 ) { return; }
Expand Down Expand Up @@ -2896,15 +2896,14 @@ function setCookie(
if ( name === '' ) { return; }
name = encodeURIComponent(name);

const validValues = new Set([
'true', 'True',
'false', 'False',
'yes', 'Yes', 'y', 'Y',
'no', 'No', 'n', 'N',
'ok', 'OK',
'Accept', 'Reject',
]);
if ( validValues.has(value) === false ) {
const validValues = [
'true', 'false',
'yes', 'y', 'no', 'n',
'ok',
'accept', 'reject',
'allow',
];
if ( validValues.includes(value.toLowerCase()) === false ) {
if ( /^\d+$/.test(value) === false ) { return; }
const n = parseInt(value, 10);
if ( n > 15 ) { return; }
Expand Down

0 comments on commit 03d0d8d

Please sign in to comment.