mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
buffer: fix atob/btoa no-arg case
PR-URL: https://github.com/nodejs/node/pull/41478 Fixes: https://github.com/nodejs/node/issues/41450 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
This commit is contained in:
parent
06625ff0a6
commit
9a8fa71020
3 changed files with 21 additions and 9 deletions
|
@ -96,6 +96,7 @@ const {
|
|||
ERR_INVALID_ARG_VALUE,
|
||||
ERR_INVALID_BUFFER_SIZE,
|
||||
ERR_OUT_OF_RANGE,
|
||||
ERR_MISSING_ARGS,
|
||||
ERR_UNKNOWN_ENCODING
|
||||
},
|
||||
hideStackFrames
|
||||
|
@ -1218,6 +1219,9 @@ function btoa(input) {
|
|||
// The implementation here has not been performance optimized in any way and
|
||||
// should not be.
|
||||
// Refs: https://github.com/nodejs/node/pull/38433#issuecomment-828426932
|
||||
if (arguments.length === 0) {
|
||||
throw new ERR_MISSING_ARGS('input');
|
||||
}
|
||||
input = `${input}`;
|
||||
for (let n = 0; n < input.length; n++) {
|
||||
if (input[n].charCodeAt(0) > 0xff)
|
||||
|
@ -1234,6 +1238,9 @@ function atob(input) {
|
|||
// The implementation here has not been performance optimized in any way and
|
||||
// should not be.
|
||||
// Refs: https://github.com/nodejs/node/pull/38433#issuecomment-828426932
|
||||
if (arguments.length === 0) {
|
||||
throw new ERR_MISSING_ARGS('input');
|
||||
}
|
||||
input = `${input}`;
|
||||
for (let n = 0; n < input.length; n++) {
|
||||
if (!kBase64Digits.includes(input[n]))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue