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

Fix handling of empty strings for set/set-attr scriptlets

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2729
This commit is contained in:
Raymond Hill 2023-07-11 15:10:27 -04:00
parent 4a83b80328
commit 6e78ee096a
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -400,7 +400,7 @@ function setConstantCore(
cValue = true;
} else if ( cValue === 'null' ) {
cValue = null;
} else if ( cValue === "''" ) {
} else if ( cValue === "''" || cValue === '' ) {
cValue = '';
} else if ( cValue === '[]' ) {
cValue = [];
@ -2994,12 +2994,11 @@ function setAttr(
) {
if ( typeof selector !== 'string' ) { return; }
if ( selector === '' ) { return; }
if ( value === '' ) { return; }
const validValues = [ '', 'false', 'true' ];
let copyFrom = '';
if ( validValues.includes(value) === false ) {
if ( validValues.includes(value.toLowerCase()) === false ) {
if ( /^\d+$/.test(value) ) {
const n = parseInt(value, 10);
if ( n >= 32768 ) { return; }