diff --git a/src/AppInstallerCLICore/Workflows/DownloadFlow.cpp b/src/AppInstallerCLICore/Workflows/DownloadFlow.cpp index a2c47cc56e..3e3d823fe2 100644 --- a/src/AppInstallerCLICore/Workflows/DownloadFlow.cpp +++ b/src/AppInstallerCLICore/Workflows/DownloadFlow.cpp @@ -69,7 +69,7 @@ namespace AppInstaller::CLI::Workflow // Assuming that we find a safe stem value in the URI, use it. // This should be extremely common, but just in case fall back to the older name style. - if (filename.has_stem() && ((filename.string().size() + installerExtension.size()) < MAX_PATH)) + if (filename.has_stem() && ((filename.wstring().size() + installerExtension.size()) < MAX_PATH)) { filename = filename.stem(); } diff --git a/src/AppInstallerCLITests/AppInstallerCLITests.vcxproj b/src/AppInstallerCLITests/AppInstallerCLITests.vcxproj index 84d1a1deb0..2c0a30246d 100644 --- a/src/AppInstallerCLITests/AppInstallerCLITests.vcxproj +++ b/src/AppInstallerCLITests/AppInstallerCLITests.vcxproj @@ -257,6 +257,9 @@ true + + true + true diff --git a/src/AppInstallerCLITests/AppInstallerCLITests.vcxproj.filters b/src/AppInstallerCLITests/AppInstallerCLITests.vcxproj.filters index 74644e7a9a..a110651b19 100644 --- a/src/AppInstallerCLITests/AppInstallerCLITests.vcxproj.filters +++ b/src/AppInstallerCLITests/AppInstallerCLITests.vcxproj.filters @@ -510,6 +510,9 @@ TestData + + TestData + TestData diff --git a/src/AppInstallerCLITests/TestData/InstallFlowTest_EncodedUrl.yaml b/src/AppInstallerCLITests/TestData/InstallFlowTest_EncodedUrl.yaml new file mode 100644 index 0000000000..509da3e4eb --- /dev/null +++ b/src/AppInstallerCLITests/TestData/InstallFlowTest_EncodedUrl.yaml @@ -0,0 +1,18 @@ +Id: AppInstallerCliTest.UrlEncodeTest +Version: 1.0.0.0 +Name: AppInstaller Test Exe Installer +Publisher: Microsoft Corporation +AppMoniker: AICLITestExe +License: Test +ProductCode: AppInstallerCliTest.TestExeInstaller +Installers: + - Arch: x64 + Url: https://EncodedUrlTest/%E6%B5%8B%E8%AF%95.exe + InstallerType: exe + Sha256: 65DB2F2AC2686C7F2FD69D4A4C6683B888DC55BFA20A0E32CA9F838B51689A3B + Switches: + Custom: /encodedUrl + SilentWithProgress: /silentwithprogress + Silent: /silence + Update: /update +ManifestVersion: 0.1.0 diff --git a/src/AppInstallerCLITests/WorkFlow.cpp b/src/AppInstallerCLITests/WorkFlow.cpp index 365aa73be5..e9c24d8b1e 100644 --- a/src/AppInstallerCLITests/WorkFlow.cpp +++ b/src/AppInstallerCLITests/WorkFlow.cpp @@ -884,6 +884,38 @@ TEST_CASE("ExeInstallFlowWithTestManifest", "[InstallFlow][workflow]") REQUIRE(installResultStr.find("/silentwithprogress") != std::string::npos); } +TEST_CASE("InstallFlow_RenameFromEncodedUrl", "[InstallFlow][workflow]") +{ + TestCommon::TempFile installResultPath("TestExeInstalled.txt"); + + std::ostringstream installOutput; + TestContext context{ installOutput, std::cin }; + auto previousThreadGlobals = context.SetForCurrentThread(); + OverrideForCheckExistingInstaller(context); + context.Override({ DownloadInstallerFile, [](TestContext& context) + { + context.Add({ {}, {} }); + auto installerPath = std::filesystem::temp_directory_path(); + installerPath /= "EncodedUrlTest.exe"; + std::filesystem::copy(TestDataFile("AppInstallerTestExeInstaller.exe"), installerPath, std::filesystem::copy_options::overwrite_existing); + context.Add(installerPath); + } }); + OverrideForUpdateInstallerMotw(context); + context.Args.AddArg(Execution::Args::Type::Manifest, TestDataFile("InstallFlowTest_EncodedUrl.yaml").GetPath().u8string()); + + InstallCommand install({}); + install.Execute(context); + INFO(installOutput.str()); + + // Verify Installer is called and parameters are passed in. + REQUIRE(std::filesystem::exists(installResultPath.GetPath())); + std::ifstream installResultFile(installResultPath.GetPath()); + REQUIRE(installResultFile.is_open()); + std::string installResultStr; + std::getline(installResultFile, installResultStr); + REQUIRE(installResultStr.find("/encodedUrl") != std::string::npos); +} + TEST_CASE("InstallFlowNonZeroExitCode", "[InstallFlow][workflow]") { TestCommon::TempFile installResultPath("TestExeInstalled.txt");