-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
[release/8.0] [Blazor] Fix type name hashing when the type has multibyte characters #52316
Conversation
Hi @github-actions[bot]. If this is not a tell-mode PR, please make sure to follow the instructions laid out in the servicing process document. |
Hi @github-actions[bot]. Please make sure you've updated the PR description to use the Shiproom Template. Also, make sure this PR is not marked as a draft and is ready-to-merge. To learn more about how to prepare a servicing PR click here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved as the original PR was already reviewed and approved,
Hi @github-actions[bot]. This PR was just approved to be included in the upcoming servicing release. Somebody from the @dotnet/aspnet-build team will get it merged when the branches are open. Until then, please make sure all the CI checks pass and the PR is reviewed. |
Span<byte> typeNameHashBytes = stackalloc byte[SHA256.HashSizeInBytes]; | ||
SHA256.HashData(typeNameBytes[..written], typeNameHashBytes); | ||
|
||
return Convert.ToHexString(typeNameHashBytes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Between the SHA computation and the string allocation, is this something that could benefit from caching? Types cardinality is fixed, could be indexed on the type name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already cached here.
Backport of #52232 to release/8.0
/cc @MackinnonBuck
[Blazor] Fix type name hashing when the type has multibyte characters
Fixes an issue where an exception gets thrown if a render mode boundary component has a type whose full name contains multibyte characters.
Description
The bug results in an exception getting thrown if the type of a component with a render mode has a full name containing multibyte characters. It especially affects cases where a component (or the namespace it's defined in) contains non-Latin characters.
This PR fixes the issue by allocating a constant-sized stack buffer and falling back to a heap-allocated buffer when the type name is too long.
Fixes #50879
Fixes #52109
Customer Impact
Blazor Apps with non-Latin code might not be able to use interactivity. The workaround is to ensure that the full name of any component serving as a render mode boundary does not contain multibyte characters.
Regression?
Render modes are a new feature in .NET 8, so this bug is not a regression.
Risk
The fix is straightforward and we have new automated tests for this scenario.
Verification
Packaging changes reviewed?