-
Notifications
You must be signed in to change notification settings - Fork 10k
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
Slashes incorrectly encoded when building URL with catchall param? #2669
Comments
From @Daniel15 on Tuesday, November 29, 2016 11:36:18 AM I never got time to look into it, these routes on my site are still broken 😞 |
From @SonicGD on Wednesday, November 30, 2016 9:21:40 AM So i did some investigation... Character encoding happens in https://github.com/aspnet/Routing/blob/dev/src/Microsoft.AspNetCore.Routing/Internal/UriBuildingContext.cs#L100 and UrlEncoder always filters '/' char - https://github.com/dotnet/corefx/blob/master/src/System.Text.Encodings.Web/src/System/Text/Encodings/Web/UrlEncoder.cs#L125 I don't see any way to configure or disable this behavior. Maybe @NTaylorMullen or @rynowak will help us? |
From @SonicGD on Wednesday, November 30, 2016 9:58:29 AM Also, even if i generate correct url - i doesn't match route. ex: [HttpGet("/{parentUrl}/files/{catPath}/{fileName}.html") where Only workaround i found is to use catchall param and then parse it with regex. And it looks ugly 😢 |
From @DeadSith on Sunday, December 11, 2016 9:02:58 AM The only way to bypass it now is to set urls in a tags using href, not built-in tag helpers. It makes it harder to refactor code, but at least you get good-looking urls. |
From @Daniel15 on Saturday, April 29, 2017 11:01:09 PM This is still broken :( I worked around it by using |
From @DamianEdwards on Tuesday, May 2, 2017 10:52:01 AM @rynowak @Eilon @danroth27 comments? |
From @Eilon on Tuesday, May 2, 2017 4:47:21 PM We'll see if we can take another look at this. The problem, if I recall, isn't so much with how to encode slashes, but rather what to do when they come back in. I believe that servers/reverse-proxies such as IIS (and no doubt others) will decode the slashes on the way in, so you don't get round-tripping of data. We spent a lot of time back in MVC 1.x-5.x trying to make this work and never could. It's possible that today things are different. |
From @Daniel15 on Tuesday, May 2, 2017 11:47:40 PM
Why would the slashes be encoded in the first place? If I have a route like |
From @Eilon on Wednesday, May 3, 2017 9:24:07 AM I believe that an incoming URL in the form |
From @kaa on Wednesday, May 3, 2017 9:45:29 AM Arguably, if it was a "normal" path segment, but this is specifically a "catch all" path segment which by its nature is going to contain slashes in unencoded form. For a normal path segment the current implementation is the expected behavior of course. Currently there is no way to create an url using the UrlHelper that fits your first form, as far as I understand. This is what we're asking for. |
@DamianEdwards @Daniel15 I think I met the same issue in the Azure Function Proxy too.. Check this out: Azure/azure-functions-host#2249 |
@danroth27, any thoughts regarding this? |
I spoke about this with @rynowak a while ago and I spoke to @Tratcher too. There are some security implications with not completely escaping the path as we need to deal with things like "/Path/../../../" but Kestrel and IIS take care of those things on the inbound path. We can special case the way we encode a catchAll parameter when we build the url by just creating a new instance of PathString (calling the constructor) and then calling ToString() on the PathString to produce the properly encoded value. The fix will probably happen somewhere around here |
This would be a breaking change, so we need to think about if we are willing to take it. |
I run into this issue in API projects quite often and the workaround is pain in the ass. So my vote to fix this in future. |
@javiercn May I ask why this issue would be a breaking change? |
@doggy8088 Because the '/' are getting encoded right now into '%2F' and they won't be if we do this change, and that has the potential to break people's apps depending on how their webservers are configured. |
@javiercn It’s obviously a bug on encoding when using catchall routing. I think there is nobody will relying on this feature and the workaround right now is not affecting if you patched this bug. If user’s backend server is using IIS, no matter what they apply this patch no not, they won’t be affected either. If user use Apache Web server, there is same things. No one will be affected. So I don’t think it’s a breaking change. |
The plan we discussed was to move to 2.2.0 |
Ah right. @mkArtakMSFT let's move to 2.2.0 and un-assign. |
We've decided to add a new feature to support this scenario in 2.2.0 |
The same trouble with Is there a workaround for it? |
I couldn't find any easy workaround so I wrote a custom |
@doggy8088 |
@develax The |
@doggy8088 If you try to pass a non-ASCII string to default |
@develax I mean this one below. Passing "xxx/yyy" in the default |
@doggy8088 guess what... you're right, it's my mistake. So, it can be useful only for the first case in order not to do encoding for each redirect, example:
But this case can be considered a bit offtopic for this thread. |
@JamesNK, @rynowak, @kichalla please consider this as part of the
|
Closing this as done! |
Hey, so how do i call an azure function that has a url segment with slashes from typescript? I have my function signature set like this: still getting errors |
I can't get this to work. My route is
also tried
Anyone has managed to make it work and can help me? |
Hi, it looks like you are posting on a closed issue/PR/commit! We're very likely to lose track of your bug/feedback/question unless you:
|
From @Daniel15 on Saturday, September 10, 2016 10:27:27 PM
Consider this controller:
When you hit
http://example.com/foo/some/url
, ASP.NET MVC Core will display:Whereas ASP.NET MVC 5 will display:
Notice that the URL returned by
Url.Action
encodes/
as%2F
, whereas the previous MVC version did not do this.Is this an expected change? If so, how do I render the URL such that the slash is not encoded?
Copied from original issue: aspnet/Routing#363
The text was updated successfully, but these errors were encountered: