aspnet / BasicMiddleware

[Archived] Basic middleware components for ASP.NET Core. Project moved to https://github.com/aspnet/AspNetCore
Apache License 2.0
169 stars 84 forks source link

rewrite middleware not identifying multiple slashes #212

Closed Eilon closed 7 years ago

Eilon commented 7 years ago

From @parmarnishant on February 10, 2017 6:16

Problem : Redirect to url with single slash if url has multiple slashes.

http://localhost/segment1///segment2//segment3

The above url when read removes multiple slashes and shows only one slash. I tried following methods to read url.

request.Path Microsoft.AspNetCore.Http.Extensions.UriHelper.GetEncodedUri (request) Microsoft.AspNetCore.Http.Extensions.UriHelper.GetDisplayUri(request)

Thanks.

Copied from original issue: aspnet/Mvc#5779

Eilon commented 7 years ago

@mikaelm12 does some lower-level component do some canonicalization before we even get to it?

cc @blowdart in case there are some security concerns here about who should canonicalize what.

blowdart commented 7 years ago

There ought to be a raw URL that rewrite works on, but generally this should be normalised in the Request classes that everything else uses.

Tratcher commented 7 years ago

I think it's IIS that removes these slashes. Then it wouldn't even show up in the original url (as received by Kestrel). @mikaelm12 to verify.

Eilon commented 7 years ago

@Tratcher yeah that's what I was thinking.

muratg commented 7 years ago

@mikaelm12 could you take a look?

mikaelm12 commented 7 years ago

IIS is removing the slashes. So it's not that the middleware isn't identifying multiple slashes, the url it gets doesn't have them. You shouldn't see this if you don't run behind IIS.