Skip to content

Encoding a slash as %2F in URI produces unexpected escaped character in route value #2655

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

Closed
aspnet-hello opened this issue Jan 2, 2018 · 2 comments
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates

Comments

@aspnet-hello
Copy link

From @epsitec on Saturday, December 2, 2017 11:46:30 PM

I am using RouteBuilder.MapGet() with this pattern:

address/{zip}/{town}

and I need to be able to pass it a town name which contains a / (such as Belmont/Lausanne) - which is done by using the address/1092/Belmont%2FLausanne. The routing works, however, the route value for town is returned with the string Belmont%2FLausanne.

If I use %25 or other characters which need to be escaped in the URI, they get automatically decoded by the router and returned as their corresponding characters in the route value. The only exception seems to be %2F.

In #363 someone suggested to use a Replace("%2F", "/") but this is just an ugly hack, because it would produce incorrect output for an URI containing %25 followed by 2F ("%252F" should map to "%2F" but with the hack, it would be changed to "/").

Copied from original issue: aspnet/Routing#502

@Eilon Eilon added area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates and removed repo:Routing labels Nov 7, 2018
@mkArtakMSFT
Copy link
Contributor

Closing this issue as there was no community involvement for quite a while now.

@poke
Copy link
Contributor

poke commented Nov 18, 2018

@mkArtakMSFT Shouldn't this be considered as a bug that should be fixed? According to the RFC, percent encoding is valid for URI path segments. But when looking at the individual value of a path segment, the URL should probably be decoded.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates
Projects
None yet
Development

No branches or pull requests

4 participants