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

[Blazor] Correctly encode non-ASCII characters in redirect URL #53623

Merged
merged 1 commit into from
Jan 26, 2024

Conversation

MackinnonBuck
Copy link
Member

Correctly encode non-ASCII characters in redirect URL

Encodes non-ASCII characters included in redirect URLs.

Description

The culprit was the use of Uri.ToString(), which decodes URL-encoded characters. This PR replaces the relevant occurrences of Uri.ToString() with Uri.AbsoluteUri, which does not perform any decoding.

Fixes #52438

@MackinnonBuck MackinnonBuck added the area-blazor Includes: Blazor, Razor Components label Jan 25, 2024
@MackinnonBuck MackinnonBuck requested a review from a team as a code owner January 25, 2024 23:08
@@ -11,7 +11,7 @@ internal sealed class HttpNavigationManager : NavigationManager, IHostEnvironmen

protected override void NavigateToCore(string uri, NavigationOptions options)
{
var absoluteUriString = ToAbsoluteUri(uri).ToString();
var absoluteUriString = ToAbsoluteUri(uri).AbsoluteUri;
Copy link
Member Author

Choose a reason for hiding this comment

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

Accessing the Uri.AbsoluteUri property will throw if the Uri instance does not represent an absolute URI, but this case is safe because ToAbsoluteUri() always returns an absolute URI.

@MackinnonBuck MackinnonBuck merged commit 335c8de into main Jan 26, 2024
@MackinnonBuck MackinnonBuck deleted the mbuck/fix-redirect-url-encoding branch January 26, 2024 17:19
@ghost ghost added this to the 9.0-preview1 milestone Jan 26, 2024
@wtgodbe wtgodbe modified the milestones: 9.0-preview1, 9.0-preview2 Jan 31, 2024
@ghost ghost added the area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework label Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework
Projects
None yet
3 participants