Skip to content

Commit

Permalink
[Fix] Uint8Array.prototype.setFromBase64: avoid invoking toString o…
Browse files Browse the repository at this point in the history
…n a non-string `string` argument

Also:
 - add test coverage from tc39/test262#3994
  • Loading branch information
ljharb committed Feb 28, 2024
1 parent 85c927f commit ef96249
Show file tree
Hide file tree
Showing 4 changed files with 470 additions and 3 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"capIsNewExceptions": [
"FromBase64",
"FromHex",
"DetachArrayBuffer",
"Get",
"GetIntrinsic",
"GetOptionsObject",
Expand Down
4 changes: 2 additions & 2 deletions Uint8Array.prototype.setFromBase64/implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = function setFromBase64(string) {
ValidateUint8Array(into); // step 2

if (typeof string !== 'string') {
throw new $TypeError('`string` is not a string: ' + string); // step 3
throw new $TypeError('`string` is not a string: ' + typeof string); // step 3
}

var opts = GetOptionsObject(arguments.length > 1 ? arguments[1] : void undefined); // step 4
Expand All @@ -41,7 +41,7 @@ module.exports = function setFromBase64(string) {
}

if (typeof alphabet !== 'string') {
throw new $TypeError('`alphabet` is not a string: ' + alphabet); // step 7
throw new $TypeError('`alphabet` is not a string: ' + typeof alphabet); // step 7
}

if (alphabet !== 'base64' && alphabet !== 'base64url') {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"evalmd": "^0.0.19",
"for-each": "^0.3.3",
"in-publish": "^2.0.1",
"is-core-module": "^2.13.1",
"npmignore": "^0.3.1",
"nyc": "^10.3.2",
"object-inspect": "^1.13.1",
Expand Down
Loading

0 comments on commit ef96249

Please sign in to comment.