Closed newbienewbie closed 6 years ago
Interesting find. Can you: A) File an issue with these details, issues are easier to track. B) Add a test for this scenario. C) Rebase onto the release/2.2 branch, that's our upcoming release and this would be a good thing to include.
If you can't take care of these in a few days then we'll see about getting someone assigned to it.
@Tratcher Hi, I've created a new issue here . I'll add tests for this scenario .
Superseded by #257.
When serving a static directory whose path string contains unicode codes , let's say
blog/categories/大道/index.html
blog/categories/大道/index.html
The
DefaultFileMiddlware
gets the directory byvar dirContents = _fileProvider.GetDirectoryContents(subpath.Value);
. And now when we check whether the path ofblog/categories/大道/
exists as below :https://github.com/aspnet/StaticFiles/blob/4c8df8e5a4e3abe5e7db51685dbd892d160c1e35/src/Microsoft.AspNetCore.StaticFiles/DefaultFilesMiddleware.cs#L69
The result will be true .
However , when coming into the default
index.html
, theDefaultFileMiddlware
checks the file path by :Here the
subpath
is often urlencoded , so the file path will be something as below :As a result ,
file.Exists
will returnfalse
.