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 should throw an error if the input is not correctly encoded #42646

Closed
zloirock opened this issue Apr 7, 2022 · 2 comments · Fixed by #42662
Closed

atob should throw an error if the input is not correctly encoded #42646

zloirock opened this issue Apr 7, 2022 · 2 comments · Fixed by #42662
Labels
buffer Issues and PRs related to the buffer subsystem. confirmed-bug Issues with confirmed bugs.

Comments

@zloirock
Copy link

zloirock commented Apr 7, 2022

Version

17.9.0

Platform

MacOS 12.2

Subsystem

global / buffer

What steps will reproduce the bug?

No response

How often does it reproduce? Is there a required condition?

No response

What is the expected behavior?

atob('a') // => DOMException
atob('a ') // => DOMException
atob('aaaaa') // => DOMException

What do you see instead?

atob('a') === ''
atob('a ') === ''
atob('aaaaa') === 'i¦\x9A'

Additional information

https://infra.spec.whatwg.org/#forgiving-base64-decode step 3

Related to #42539 / #42530 @aduh95

zloirock added a commit to zloirock/core-js that referenced this issue Apr 8, 2022
@VoltrexKeyva VoltrexKeyva added the buffer Issues and PRs related to the buffer subsystem. label Apr 8, 2022
@austinkelleher
Copy link
Contributor

I'd be happy to take a look at this one and open a PR!

@aduh95
Copy link
Contributor

aduh95 commented Apr 8, 2022

Thanks for volunteering @austinkelleher, PR’s welcome :)

@aduh95 aduh95 added the confirmed-bug Issues with confirmed bugs. label Apr 8, 2022
austinkelleher added a commit to austinkelleher/node that referenced this issue Apr 8, 2022
The specification of `atob` has various different conditions that we need
to abide by. The specific changes that were made:

* `atob` now immediately throws when `undefined`, `false`, or a `number` is
  supplied
* `atob` now strips ASCII whitespace before attempting to decode
* `atob` now validates that the code point's length divided by 4 leaves a
  remainder that is not 1

See: https://infra.spec.whatwg.org/#forgiving-base64-decode

Fixes: nodejs#42646
austinkelleher added a commit to austinkelleher/node that referenced this issue Apr 8, 2022
The specification of `atob` has various different conditions that we
need to abide by. The specific changes that were made:

* `atob` now immediately throws when `undefined`, `false`, or a `number`
  is supplied
* `atob` now strips ASCII whitespace before attempting to decode
* `atob` now validates that the code point's length divided by 4 leaves a
  remainder that is not 1

See: https://infra.spec.whatwg.org/#forgiving-base64-decode

Fixes: nodejs#42646
austinkelleher added a commit to austinkelleher/node that referenced this issue Apr 8, 2022
The specification of `atob` has various different conditions that we
need to abide by. The specific changes that were made:

* `atob` now immediately throws when `undefined`, `false`, or a `number`
  is supplied
* `atob` now strips ASCII whitespace before attempting to decode
* `atob` now validates that the code point's length divided by 4 leaves
  a remainder that is not 1

See: https://infra.spec.whatwg.org/#forgiving-base64-decode

Fixes: nodejs#42646
austinkelleher added a commit to austinkelleher/node that referenced this issue Apr 9, 2022
The specification of `atob` has various different conditions that we
need to abide by. The specific changes that were made:

* `atob` now immediately throws when `undefined`, `false`, or a `number`
  is supplied
* `atob` now strips ASCII whitespace before attempting to decode
* `atob` now validates that the code point's length divided by 4 leaves
  a remainder that is not 1

See: https://infra.spec.whatwg.org/#forgiving-base64-decode

Fixes: nodejs#42646
aduh95 pushed a commit that referenced this issue Apr 12, 2022
This commit fixes a few inconsistencies between Node.js `atob`
implementation and the WHATWG spec.

Refs: https://infra.spec.whatwg.org/#forgiving-base64-decode
Fixes: #42646
PR-URL: #42662
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com>
vmoroz pushed a commit to vmoroz/node that referenced this issue Apr 13, 2022
This commit fixes a few inconsistencies between Node.js `atob`
implementation and the WHATWG spec.

Refs: https://infra.spec.whatwg.org/#forgiving-base64-decode
Fixes: nodejs#42646
PR-URL: nodejs#42662
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com>
xtx1130 pushed a commit to xtx1130/node that referenced this issue Apr 25, 2022
This commit fixes a few inconsistencies between Node.js `atob`
implementation and the WHATWG spec.

Refs: https://infra.spec.whatwg.org/#forgiving-base64-decode
Fixes: nodejs#42646
PR-URL: nodejs#42662
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com>
juanarbol pushed a commit that referenced this issue May 31, 2022
This commit fixes a few inconsistencies between Node.js `atob`
implementation and the WHATWG spec.

Refs: https://infra.spec.whatwg.org/#forgiving-base64-decode
Fixes: #42646
PR-URL: #42662
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com>
targos pushed a commit that referenced this issue Sep 16, 2022
This commit fixes a few inconsistencies between Node.js `atob`
implementation and the WHATWG spec.

Refs: https://infra.spec.whatwg.org/#forgiving-base64-decode
Fixes: #42646
PR-URL: #42662
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com>
juanarbol pushed a commit that referenced this issue Oct 10, 2022
This commit fixes a few inconsistencies between Node.js `atob`
implementation and the WHATWG spec.

Refs: https://infra.spec.whatwg.org/#forgiving-base64-decode
Fixes: #42646
PR-URL: #42662
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com>
juanarbol pushed a commit that referenced this issue Oct 11, 2022
This commit fixes a few inconsistencies between Node.js `atob`
implementation and the WHATWG spec.

Refs: https://infra.spec.whatwg.org/#forgiving-base64-decode
Fixes: #42646
PR-URL: #42662
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com>
guangwong pushed a commit to noslate-project/node that referenced this issue Jan 3, 2023
This commit fixes a few inconsistencies between Node.js `atob`
implementation and the WHATWG spec.

Refs: https://infra.spec.whatwg.org/#forgiving-base64-decode
Fixes: nodejs/node#42646
PR-URL: nodejs/node#42662
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com>
guangwong pushed a commit to noslate-project/node that referenced this issue Jan 3, 2023
This commit fixes a few inconsistencies between Node.js `atob`
implementation and the WHATWG spec.

Refs: https://infra.spec.whatwg.org/#forgiving-base64-decode
Fixes: nodejs/node#42646
PR-URL: nodejs/node#42662
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
buffer Issues and PRs related to the buffer subsystem. confirmed-bug Issues with confirmed bugs.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants