Unicode path in static files middleware (#411)
This commit is contained in:
Родитель
d196e785e2
Коммит
d702a05e83
|
@ -70,7 +70,7 @@ namespace Microsoft.Owin.StaticFiles
|
|||
string defaultFile = _options.DefaultFileNames[matchIndex];
|
||||
IFileInfo file;
|
||||
// TryMatchPath will make sure subpath always ends with a "/" by adding it if needed.
|
||||
if (_options.FileSystem.TryGetFileInfo(subpath + defaultFile, out file))
|
||||
if (_options.FileSystem.TryGetFileInfo(subpath.Value + defaultFile, out file))
|
||||
{
|
||||
// If the path matches a directory but does not end in a slash, redirect to add the slash.
|
||||
// This prevents relative links from breaking.
|
||||
|
|
|
@ -61,6 +61,8 @@ namespace Microsoft.Owin.StaticFiles.Tests
|
|||
[InlineData("", @".\", "/SubFolder/")]
|
||||
[InlineData("", @"SubFolder", "/")]
|
||||
[InlineData("", @".\SubFolder", "/")]
|
||||
[InlineData("", @"./SubFolder", "/你好/")]
|
||||
[InlineData("", @"./SubFolder", "/你好/世界/")]
|
||||
public void FoundDirectoryWithDefaultFile_PathModified(string baseUrl, string baseDir, string requestUrl)
|
||||
{
|
||||
IAppBuilder builder = new AppBuilder();
|
||||
|
|
|
@ -108,6 +108,12 @@
|
|||
<Content Include="SubFolder\Default.html">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="SubFolder\你好\Default.html">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="SubFolder\你好\世界\Default.html">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<None Include="SubFolder\Ranges.txt">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title></title>
|
||||
</head>
|
||||
<body>
|
||||
Hello World
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title></title>
|
||||
</head>
|
||||
<body>
|
||||
Hello World
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче