Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

atob() return is not limited to ASCII #2315

Open
dckc opened this issue Jun 12, 2024 · 1 comment
Open

atob() return is not limited to ASCII #2315

dckc opened this issue Jun 12, 2024 · 1 comment

Comments

@dckc
Copy link
Contributor

dckc commented Jun 12, 2024

Docs say it returns ASCII:

* @returns {string} an ASCII string containing decoded data from `encodedData`

not so:

test('really ascii?', t => {
  const data = new Uint8Array([0x6e, 0xf1]);
  const encoded = encodeBase64(data);
  const actual = atob(encoded);
  const ascii = /^[\x20-\x7f]+$/;
  t.log(actual);
  t.regex(actual, ascii);
});
@kriskowal
Copy link
Member

Aye, this should be revised to “string where each character’s code point is the value of the corresponding byte in the range 0 to 255” or words to that effect.

https://developer.mozilla.org/en-US/docs/Glossary/Base64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants