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] Fixes encoded / on Blazor Router #53538

Merged
merged 1 commit into from
Feb 6, 2024

Conversation

javiercn
Copy link
Member

@javiercn javiercn commented Jan 22, 2024

Fixes handling of encoded values within Blazor Routing

As part of .NET 8.0 we replaced the Blazor Router implementation with an equivalent implementation provided by ASP.NET to bring the Blazor implementation to out of the box feature parity with the ASP.NET implementation.

As part of that, we changed the way encoded are processed before we handle them to the Blazor router, which resulted in a regression as we were eagerly decoding %2F (/) values. In addition to that, we also determined that the values were not being decoded (a custom step that Blazor does)

Description

  • .NET 8.0 is incorrectly decoding %2F characters in the path before running routing.
  • .NET 8.0 SSR is not decoding the route values on the server before passing them as parameters to a component.

Fixes #52808, #53138, #53262 #53668

Customer Impact

  • Customers that put encoded / in their application paths (for example, route parameters that take in a URL) won't be able to do so.
  • Customers that use values that are URL encoded, will see the URL encoded value in server implementations and the unencoded value in the interactive implementations.

Regression?

  • Yes
  • No

7.0, the values were presented unencoded to the user and %2F was handled correctly and route values were decoded before being passed as parameters.

Risk

  • High
  • Medium
  • Low

We've added automated tests to validate that the scenario behaves correctly and tests that verify that the implementation on the server and the client behaves consistently and accordingly to previous Blazor versions.

We've replaced the implementation that was handling the decoding in the Blazor Router (which was the source of the problem) with the implementation used by ASP.NET Core.

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

When servicing release/2.1

  • Make necessary changes in eng/PatchConfig.props

As part of the routing unification process we switched the way we were
decoding the URL prior to feeding it to routing and that introduced a
small regression in interactive routing compared to .NET 7.0.

This commit fixes that regression by using the same logic for decoding
the URL in the client that is used on the server.

In addition to that, the Blazor router now post processes the URL to
replace instances of `%2F` with `/` when providing values to maintain
the behavior in 7.0 where it used UnescapeDataString.

This also makes the routing on the server and on the client consistent
in their handling of encoded `/` characters.
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-blazor Includes: Blazor, Razor Components label Jan 22, 2024
@javiercn javiercn added the Servicing-consider Shiproom approval is required for the issue label Jan 29, 2024
@ghost
Copy link

ghost commented Jan 29, 2024

Hi @javiercn. 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.

@javiercn javiercn marked this pull request as ready for review January 29, 2024 14:05
@javiercn javiercn requested a review from a team as a code owner January 29, 2024 14:05
@mkArtakMSFT mkArtakMSFT added Servicing-approved Shiproom has approved the issue and removed Servicing-consider Shiproom approval is required for the issue labels Feb 5, 2024
@ghost
Copy link

ghost commented Feb 5, 2024

Hi @javiercn. 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.

@wtgodbe wtgodbe merged commit cdd2342 into release/8.0 Feb 6, 2024
@wtgodbe wtgodbe deleted the javiercn/backport-issue-53138 branch February 6, 2024 22:29
@dotnet-policy-service dotnet-policy-service bot added this to the 8.0.3 milestone Feb 6, 2024
@dotnet-policy-service dotnet-policy-service bot added the area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework label Feb 6, 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 Servicing-approved Shiproom has approved the issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants