Skip to content

Commit

Permalink
Fix handling of empty strings for set/set-attr scriptlets
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Jul 11, 2023
1 parent 4a83b80 commit 6e78ee0
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions assets/resources/scriptlets.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down Expand Up @@ -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; }
Expand Down

0 comments on commit 6e78ee0

Please sign in to comment.