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 (Server) route does not match when complex characters are in the url #53262

Closed
1 task done
Sebazzz opened this issue Jan 10, 2024 · 3 comments
Closed
1 task done
Labels
area-blazor Includes: Blazor, Razor Components bug This issue describes a behavior which is not expected - a bug.
Milestone

Comments

@Sebazzz
Copy link

Sebazzz commented Jan 10, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Kind-of a regression of #16840 (fixed in PR #26769), a route is defined for a page with a placeholder. However, when there are weird characters in the URL it doesn't match the route for the page. This worked in .NET 7 and is broken in .NET 8.

In .NET 8 the route does not match:

dbug: Microsoft.AspNetCore.Components.Routing.Router[3]
      Navigating to non-component URI 'http://localhost:5110/project/asdasd/ruimte/fb6566f385ab4e11a27f3393bb22c8ff/bron/%21%40%23%24%25%5E%26%2A%28%29_%2B-%3D%5B%5D%7B%7D%5C%5C%7C%3B%27%3A%5C%22%3E%3F.%2F/bewerken' in response to path '/project/asdasd/ruimte/fb6566f385ab4e11a27f3393bb22c8ff/bron/%21%40%23%24%25%5E%26%2A%28%29_%2B-%3D%5B%5D%7B%7D%5C%5C%7C%3B%27%3A%5C%22%3E%3F.%2F/bewerken' with base URI 'http://localhost:5110/'
dbug: Microsoft.AspNetCore.Components.Routing.Router[1]
      Displaying NotFound because path '/project/asdasd/ruimte/fb6566f385ab4e11a27f3393bb22c8ff/bron/%21%40%23%24%25%5E%26%2A%28%29_%2B-%3D%5B%5D%7B%7D%5C%5C%7C%3B%27%3A%5C%22%3E%3F.%2F/bewerken' with base URI 'http://localhost:5110/' does not match any component route

Expected Behavior

In .NET 7 the route matches and this is logged:

dbug: Microsoft.AspNetCore.Components.Routing.Router[2]
      Navigating to component dotnet_bug.Pages.MyComponent in response to path 'project/asdasd/ruimte/fb6566f385ab4e11a27f3393bb22c8ff/bron/%21%40%23%24%25%5E%26%2A%28%29_%2B-%3D%5B%5D%7B%7D%5C%5C%7C%3B%27%3A%5C%22%3E%3F.%2F/bewerken' with base URI 'http://localhost:5110/'
dbug: Microsoft.AspNetCore.Components.Routing.Router[2]
      Navigating to component dotnet_bug.Pages.MyComponent in response to path 'project/asdasd/ruimte/fb6566f385ab4e11a27f3393bb22c8ff/bron/%21%40%23%24%25%5E%26%2A%28%29_%2B-%3D%5B%5D%7B%7D%5C%5C%7C%3B%27%3A%5C%22%3E%3F.%2F/bewerken' with base URI 'http://localhost:5110/'
dbug: Microsoft.AspNetCore.Components.Routing.Router[2]
      Navigating to component dotnet_bug.Pages.MyComponent in response to path 'project/asdasd/ruimte/fb6566f385ab4e11a27f3393bb22c8ff/bron/%21%40%23%24%25%5E%26%2A%28%29_%2B-%3D%5B%5D%7B%7D%5C%5C%7C%3B%27%3A%5C%22%3E%3F.%2F/bewerken' with base URI 'http://localhost:5110/'
dbug: Microsoft.AspNetCore.Components.Routing.Router[1]
      Displaying NotFound because path 'project/asdasd/ruimte/fb6566f385ab4e11a27f3393bb22c8ff/bron/!%40%23%24%25%5E%26*()_%2B-%3D[]%7B%7D//|%3B'%3A/%22%3E%3F.%2F/bewerken' with base URI 'http://localhost:5110/' does not match any component route
dbug: Microsoft.AspNetCore.Components.Routing.Router[1]
      Displaying NotFound because path 'project/asdasd/ruimte/fb6566f385ab4e11a27f3393bb22c8ff/bron/!%40%23%24%25%5E%26*()_%2B-%3D[]%7B%7D//|%3B'%3A/%22%3E%3F.%2F/bewerken' with base URI 'http://localhost:5110/' does not match any component route

Steps To Reproduce

Given a component with this route:

@page "/project/{projectCode}/ruimte/{publicAreaId}/bron/{sourceCode}/bewerken"

And URL:

/project/asdasd/ruimte/fb6566f385ab4e11a27f3393bb22c8ff/bron/%21%40%23%24%25%5E%26%2A%28%29_%2B-%3D%5B%5D%7B%7D%5C%5C%7C%3B%27%3A%5C%22%3E%3F.%2F/bewerken

The sourceCode part !@#$%^&*()_+-=[]{}\\|;':\">?./ is url-encoded.

Full repro: dotnet-bug.zip

Exceptions (if any)

No response

.NET Version

8.0.100

Anything else?

.NET 7.0:

net7-0

.NET 8.0, identical code:

net8-0

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-blazor Includes: Blazor, Razor Components label Jan 10, 2024
@Sebazzz Sebazzz changed the title Blazor (Server) route does not match when complex characters are in the url and client-side is performed Blazor (Server) route does not match when complex characters are in the url Jan 10, 2024
@TDroogers
Copy link

Sounds related to my bug #53138

@javiercn
Copy link
Member

This is now fixed in main; we'll probably backport it to 8.0 in a future patch release. #53470

@mkArtakMSFT
Copy link
Member

@Sebazzz did you by any chance try the fix out from the nightly build to see if this indeed has addressed the issue you were facing? It most probably did but would be nice to get confirmation.

@mkArtakMSFT mkArtakMSFT added this to the 8.0.3 milestone Feb 9, 2024
@mkArtakMSFT mkArtakMSFT added the bug This issue describes a behavior which is not expected - a bug. label Feb 9, 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 bug This issue describes a behavior which is not expected - a bug.
Projects
None yet
Development

No branches or pull requests

4 participants