Skip to content

Allow UTF-16 surrogate pairs in Base64 decoded strings#64

Open
dchristensen wants to merge 2 commits intoDevToys-app:mainfrom
dchristensen:base64_surrogate_pairs
Open

Allow UTF-16 surrogate pairs in Base64 decoded strings#64
dchristensen wants to merge 2 commits intoDevToys-app:mainfrom
dchristensen:base64_surrogate_pairs

Conversation

@dchristensen
Copy link

@dchristensen dchristensen commented Nov 27, 2024

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • New feature or enhancement
  • UI change (please include screenshot!)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Internationalization and localization
  • Other (please describe):

What is the current behavior?

Base64 decoding fails with <Invalid Base64> when UTF-16 surrogate pairs are encountered. Surrogate pairs allow the Unicode encoding to encode characters with codepoints greater than 0xFFFF in UTF-16. In the linked issue the the example document includes the key emoji (🗝️) which is represented in UTF-16 as \ud83d\udddd.

Issue Number: DevToys-app/DevToys#1461

What is the new behavior?

  • Expand the allowed character ranges to include the UTF-16 surrogate pair ranges
    • U+D800—U+DBFF (high surrogates)
    • U+DC00—U+DFFF (low surrogates)
  • Removed an invalid range check. Previously the code was attempting to check for codepoints greater than 0xFFFF, but used a 32-bit integer value.

Other information

Unicode documentation for UTF-16 surrogate pairs

Quality check

Before creating this PR:

  • Did you follow the code style guideline as described in CONTRIBUTING.md
  • Did you build the app and test your changes?
  • Did you check for accessibility? On Windows, you can use Accessibility Insights for this.
  • Did you verify that the change work in Release build configuration
  • Did you verify that all unit tests pass
  • If necessary and if possible, did you verify your changes on:
    • Windows
    • macOS
    • Linux

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

Successfully merging this pull request may close these issues.

1 participant