Shield against possible case of invalid attribute name

Not sure this can really happen, but if ever Math.random() would
return `0.9999999999999999`, the attribute name would start with
`{`, i.e. an invalid attribute name.
This commit is contained in:
Raymond Hill 2021-10-26 08:55:05 -04:00
parent 5bea149e8f
commit b1a338681b
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 1 additions and 1 deletions

View File

@ -40,7 +40,7 @@ if (
vAPI.randomToken = function() { vAPI.randomToken = function() {
const n = Math.random(); const n = Math.random();
return String.fromCharCode(n * 26 + 97) + return String.fromCharCode(n * 25 + 97) +
Math.floor( Math.floor(
(0.25 + n * 0.75) * Number.MAX_SAFE_INTEGER (0.25 + n * 0.75) * Number.MAX_SAFE_INTEGER
).toString(36).slice(-8); ).toString(36).slice(-8);