Skip to content

Conversation

@ilonatommy
Copy link
Member

@ilonatommy ilonatommy commented Oct 27, 2025

Fixes #117116.

  • Call CheckNormalizationForm before the ASCII fast path so Browser/WASI throw PlatformNotSupportedException for FormKC/FormKD regardless of input.
  • Add wasm-specific test for checking if PNSE was thrown for both, ASCII and non-ASCII with KC and KD.

Why didn't we catch it in tests?
Because we do not test KC/KD at all, considering them not supported (IsNotUsingLimitedCultures -> Browser with its ICU):

if (PlatformDetection.IsNotUsingLimitedCultures || PlatformDetection.IsHybridGlobalizationOnApplePlatform)

@ilonatommy ilonatommy self-assigned this Oct 27, 2025
Copilot AI review requested due to automatic review settings October 27, 2025 10:26
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug where Browser/WASI platforms inconsistently threw PlatformNotSupportedException for FormKC/FormKD normalization forms. The issue occurred when the input string was ASCII-only, as the exception was only thrown after the ASCII fast path check. The fix ensures that the exception is thrown consistently regardless of input by checking for unsupported forms earlier in the validation process.

Key changes:

  • Moved compatibility form validation before the ASCII fast path to ensure consistent exception behavior
  • Consolidated duplicate Browser/WASI guard logic into a reusable ThrowIfCompatibilityFormUnsupported method
  • Added additional validation checks (Invariant and UseNls modes) to the guard conditions

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/libraries/System.Private.CoreLib/src/System/Globalization/Normalization.cs Added new ThrowIfCompatibilityFormUnsupported method and called it from CheckNormalizationForm to validate compatibility forms before ASCII fast path
src/libraries/System.Private.CoreLib/src/System/Globalization/Normalization.Icu.cs Replaced inline Browser/WASI check with call to the new consolidated ThrowIfCompatibilityFormUnsupported method

@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-globalization
See info in area-owners.md if you want to be subscribed.

@ilonatommy ilonatommy enabled auto-merge (squash) October 29, 2025 09:24
Copy link
Member

@tarekgh tarekgh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left one final comment. LGTM otherwise.

@ilonatommy
Copy link
Member Author

/ba-g windows-arm64 Release NativeAOT, windows-arm64 Release NativeAOT_Libraries and coreclr Pri0 Runtime Tests Run windows arm64 checked timeouts are not connected with the change.

@ilonatommy ilonatommy merged commit de62bfc into dotnet:main Oct 31, 2025
138 of 142 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[WASM] string Normalize() / IsNormalized() compatibility forms

3 participants