mirror of
https://github.com/microsoft/WSL.git
synced 2025-12-10 17:47:59 -06:00
Don't try to create invalid file names if the distribution download url contains parameters (#13109)
This commit is contained in:
parent
02ca6d3d2d
commit
c3f59f8b12
@ -285,7 +285,8 @@ void wsl::windows::common::distribution::LegacyInstallViaGithub(const Distributi
|
|||||||
|
|
||||||
wslutil::PrintMessage(Localization::MessageDownloading(distro.FriendlyName.c_str()), stdout);
|
wslutil::PrintMessage(Localization::MessageDownloading(distro.FriendlyName.c_str()), stdout);
|
||||||
|
|
||||||
const auto downloadPath = wslutil::DownloadFile(*downloadUrl);
|
// Note: The appx extensions is required for the installation to succeed.
|
||||||
|
const auto downloadPath = wslutil::DownloadFile(*downloadUrl, distro.Name + L".appx");
|
||||||
auto deleteFile =
|
auto deleteFile =
|
||||||
wil::scope_exit_log(WI_DIAGNOSTICS_INFO, [&] { THROW_IF_WIN32_BOOL_FALSE(DeleteFileW(downloadPath.c_str())); });
|
wil::scope_exit_log(WI_DIAGNOSTICS_INFO, [&] { THROW_IF_WIN32_BOOL_FALSE(DeleteFileW(downloadPath.c_str())); });
|
||||||
|
|
||||||
|
|||||||
@ -300,7 +300,7 @@ std::pair<std::wstring, GUID> WslInstall::InstallModernDistribution(
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
PrintMessage(Localization::MessageDownloading(distribution.FriendlyName.c_str()), stdout);
|
PrintMessage(Localization::MessageDownloading(distribution.FriendlyName.c_str()), stdout);
|
||||||
installPath = DownloadFile(downloadInfo->Url);
|
installPath = DownloadFile(downloadInfo->Url, distribution.Name + L".wsl");
|
||||||
fileDownloaded = true;
|
fileDownloaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -82,7 +82,7 @@ std::wstring ConstructPipePath(_In_ std::wstring_view PipeName);
|
|||||||
|
|
||||||
GUID CreateV5Uuid(const GUID& namespaceGuid, const std::span<const std::byte> name);
|
GUID CreateV5Uuid(const GUID& namespaceGuid, const std::span<const std::byte> name);
|
||||||
|
|
||||||
std::wstring DownloadFile(std::wstring_view Url, std::wstring Filename = L"");
|
std::wstring DownloadFile(std::wstring_view Url, std::wstring Filename);
|
||||||
|
|
||||||
[[nodiscard]] HANDLE DuplicateHandleFromCallingProcess(_In_ HANDLE handleInTarget);
|
[[nodiscard]] HANDLE DuplicateHandleFromCallingProcess(_In_ HANDLE handleInTarget);
|
||||||
|
|
||||||
|
|||||||
@ -5269,6 +5269,46 @@ Error code: Wsl/InstallDistro/E_UNEXPECTED\r\n",
|
|||||||
Error code: Wsl/InstallDistro/WSL_E_INVALID_JSON\r\n",
|
Error code: Wsl/InstallDistro/WSL_E_INVALID_JSON\r\n",
|
||||||
L"");
|
L"");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Validate that url parameters are correctly handled.
|
||||||
|
{
|
||||||
|
constexpr auto tarEndpoint = L"http://127.0.0.1:6667/";
|
||||||
|
|
||||||
|
UniqueWebServer fileServer(tarEndpoint, std::filesystem::path(g_testDistroPath));
|
||||||
|
|
||||||
|
wil::unique_handle tarHandle{CreateFile(g_testDistroPath.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr)};
|
||||||
|
VERIFY_IS_TRUE(!!tarHandle);
|
||||||
|
|
||||||
|
auto manifest = std::format(
|
||||||
|
R"({{
|
||||||
|
"ModernDistributions": {{
|
||||||
|
"test": [
|
||||||
|
{{
|
||||||
|
"Name": "test-url-download",
|
||||||
|
"FriendlyName": "FriendlyName",
|
||||||
|
"Default": true,
|
||||||
|
"Amd64Url": {{
|
||||||
|
"Url": "{}/distro.tar?foo=bar&key=value",
|
||||||
|
"Sha256": "{}"
|
||||||
|
}}
|
||||||
|
}}
|
||||||
|
]
|
||||||
|
}}}})",
|
||||||
|
tarEndpoint,
|
||||||
|
tarHash);
|
||||||
|
|
||||||
|
auto restore = SetManifest(manifest);
|
||||||
|
|
||||||
|
auto cleanup = wil::scope_exit_log(WI_DIAGNOSTICS_INFO, []() { UnregisterDistribution(L"test-url-download"); });
|
||||||
|
|
||||||
|
auto [output, error] = LxsstuLaunchWslAndCaptureOutput(L"--install --no-launch test-url-download");
|
||||||
|
VERIFY_ARE_EQUAL(
|
||||||
|
output,
|
||||||
|
L"Downloading: FriendlyName\r\nInstalling: FriendlyName\r\nDistribution successfully installed. It can be "
|
||||||
|
L"launched via 'wsl.exe -d test-url-download'\r\n");
|
||||||
|
|
||||||
|
VERIFY_ARE_EQUAL(error, L"");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_METHOD(ModernInstallEndToEnd)
|
TEST_METHOD(ModernInstallEndToEnd)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user