diff --git a/src/IISLib/util.cxx b/src/IISLib/util.cxx index bde325025e..214ee65abf 100644 --- a/src/IISLib/util.cxx +++ b/src/IISLib/util.cxx @@ -61,13 +61,17 @@ Return Values: return hr; } } - else + else if (wcslen(pszName) > MAX_PATH) { if (FAILED(hr = pstrPath->Copy(L"\\\\?\\"))) { return hr; } } + else + { + pstrPath->Reset(); + } return pstrPath->Append(pszName); } diff --git a/test/AspNetCoreModuleTests/hostfxr_utility_tests.cpp b/test/AspNetCoreModuleTests/hostfxr_utility_tests.cpp index bd6528624a..7e1d6f8d89 100644 --- a/test/AspNetCoreModuleTests/hostfxr_utility_tests.cpp +++ b/test/AspNetCoreModuleTests/hostfxr_utility_tests.cpp @@ -71,7 +71,7 @@ namespace AspNetCoreModuleTests Assert::AreEqual(DWORD(3), retVal); Assert::AreEqual(exeStr, bstrArray[0]); Assert::AreEqual(L"exec", bstrArray[1]); - Assert::AreEqual(L"\\\\?\\C:\\test\\test.dll", bstrArray[2]); + Assert::AreEqual(L"C:\\test\\test.dll", bstrArray[2]); } TEST_METHOD(ParseHostfxrArguments_ProvideNoArgs_InvalidArgs) diff --git a/test/IISIntegration.FunctionalTests/Inprocess/ServerVariablesTest.cs b/test/IISIntegration.FunctionalTests/Inprocess/ServerVariablesTest.cs index f86b3bcffd..d6fd676346 100644 --- a/test/IISIntegration.FunctionalTests/Inprocess/ServerVariablesTest.cs +++ b/test/IISIntegration.FunctionalTests/Inprocess/ServerVariablesTest.cs @@ -28,8 +28,13 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests [ConditionalFact] public async Task ReturnsNullForUndefinedServerVariable() { - var port = _fixture.Client.BaseAddress.Port; Assert.Equal("THIS_VAR_IS_UNDEFINED: (null)", await _fixture.Client.GetStringAsync("/ServerVariable?q=THIS_VAR_IS_UNDEFINED")); } + + [ConditionalFact] + public async Task BasePathIsNotPrefixedBySlashSlashQuestionMark() + { + Assert.DoesNotContain(@"\\?\", await _fixture.Client.GetStringAsync("/BasePath")); + } } } diff --git a/test/IISTestSite/Startup.cs b/test/IISTestSite/Startup.cs index 00b83e769d..781601aea5 100644 --- a/test/IISTestSite/Startup.cs +++ b/test/IISTestSite/Startup.cs @@ -667,5 +667,10 @@ namespace IISTestSite } }); } + + private void BasePath(IApplicationBuilder app) + { + app.Run(async ctx => { await ctx.Response.WriteAsync(AppDomain.CurrentDomain.BaseDirectory); }); + } } }