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

buffer: atob throw error when the input value is invalid #42662

Merged
merged 6 commits into from
Apr 12, 2022

Commits on Apr 9, 2022

  1. buffer: atob throw error when the input value is invalid

    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 committed Apr 9, 2022
    Configuration menu
    Copy the full SHA
    6f69681 View commit details
    Browse the repository at this point in the history
  2. buffer: simplify atob approach of disregarding whitespace

    * Use approach of counting non-ASCII whitespace characters instead of
      removing the characters via string replacement
    * Additional atob validation tests have been added
    austinkelleher committed Apr 9, 2022
    Configuration menu
    Copy the full SHA
    08e4c75 View commit details
    Browse the repository at this point in the history
  3. buffer: switch to using InvalidCharacterError on encoding error

    * Chrome and Firefox both use `InvalidCharacterError` when the string
      to be decoded is not correctly encoded
    * Remove unnecessary atob test
    austinkelleher committed Apr 9, 2022
    Configuration menu
    Copy the full SHA
    a85b856 View commit details
    Browse the repository at this point in the history
  4. buffer: update character validation approach in atob

    * Small optimization in atob validation by assuming positions of
      whitespace characters in allowed chars array
    * Improved tests for ASCII whitespace characters
    * Explicitly validate properties of `DOMException` in tests
    austinkelleher committed Apr 9, 2022
    Configuration menu
    Copy the full SHA
    a5828d8 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    48d6cee View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    5cee1b4 View commit details
    Browse the repository at this point in the history