From 5ea3d81a5c4bdabdd45e40bb6c9de1d4e2d29194 Mon Sep 17 00:00:00 2001 From: Kaleb Luedtke Date: Thu, 29 Sep 2022 20:35:20 -0500 Subject: [PATCH 1/5] Make Symlink Target Lexically Normal --- src/AppInstallerCommonCore/Filesystem.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/AppInstallerCommonCore/Filesystem.cpp b/src/AppInstallerCommonCore/Filesystem.cpp index 25d9bc2629..63705382e6 100644 --- a/src/AppInstallerCommonCore/Filesystem.cpp +++ b/src/AppInstallerCommonCore/Filesystem.cpp @@ -152,7 +152,7 @@ namespace AppInstaller::Filesystem #endif try { - std::filesystem::create_symlink(target, link); + std::filesystem::create_symlink(target.lexically_normal(), link); return true; } catch (std::filesystem::filesystem_error& error) @@ -170,7 +170,7 @@ namespace AppInstaller::Filesystem bool VerifySymlink(const std::filesystem::path& symlink, const std::filesystem::path& target) { - const std::filesystem::path& symlinkTargetPath = std::filesystem::read_symlink(symlink); + const std::filesystem::path& symlinkTargetPath = std::filesystem::read_symlink(symlink).lexically_normal(); return symlinkTargetPath == target; } From a0db34bb24c34d4c52fcd9a07c8d8536fef68941 Mon Sep 17 00:00:00 2001 From: Kaleb Luedtke Date: Fri, 30 Sep 2022 14:18:41 -0500 Subject: [PATCH 2/5] weakly_canonical --- src/AppInstallerCommonCore/Filesystem.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/AppInstallerCommonCore/Filesystem.cpp b/src/AppInstallerCommonCore/Filesystem.cpp index 63705382e6..3f1dbd0c29 100644 --- a/src/AppInstallerCommonCore/Filesystem.cpp +++ b/src/AppInstallerCommonCore/Filesystem.cpp @@ -152,7 +152,7 @@ namespace AppInstaller::Filesystem #endif try { - std::filesystem::create_symlink(target.lexically_normal(), link); + std::filesystem::create_symlink(target.weakly_canonical(), link); return true; } catch (std::filesystem::filesystem_error& error) @@ -170,7 +170,7 @@ namespace AppInstaller::Filesystem bool VerifySymlink(const std::filesystem::path& symlink, const std::filesystem::path& target) { - const std::filesystem::path& symlinkTargetPath = std::filesystem::read_symlink(symlink).lexically_normal(); + const std::filesystem::path& symlinkTargetPath = std::filesystem::read_symlink(symlink).weakly_canonical(); return symlinkTargetPath == target; } From a77f6c2b893757a3b56a8f56d0aec6ec78b437ac Mon Sep 17 00:00:00 2001 From: Kaleb Luedtke Date: Fri, 30 Sep 2022 14:46:30 -0500 Subject: [PATCH 3/5] Trenly fixes his noob mistake --- src/AppInstallerCommonCore/Filesystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AppInstallerCommonCore/Filesystem.cpp b/src/AppInstallerCommonCore/Filesystem.cpp index 3f1dbd0c29..3b0f9dfaca 100644 --- a/src/AppInstallerCommonCore/Filesystem.cpp +++ b/src/AppInstallerCommonCore/Filesystem.cpp @@ -170,7 +170,7 @@ namespace AppInstaller::Filesystem bool VerifySymlink(const std::filesystem::path& symlink, const std::filesystem::path& target) { - const std::filesystem::path& symlinkTargetPath = std::filesystem::read_symlink(symlink).weakly_canonical(); + const std::filesystem::path& symlinkTargetPath = std::filesystem::weakly_canonical(symlink); return symlinkTargetPath == target; } From e6d4b5e22de6832642a5e1f790cec7a8ccd397b6 Mon Sep 17 00:00:00 2001 From: Kaleb Luedtke Date: Fri, 30 Sep 2022 15:01:10 -0500 Subject: [PATCH 4/5] Change the creation too --- src/AppInstallerCommonCore/Filesystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AppInstallerCommonCore/Filesystem.cpp b/src/AppInstallerCommonCore/Filesystem.cpp index 3b0f9dfaca..56ff615dbd 100644 --- a/src/AppInstallerCommonCore/Filesystem.cpp +++ b/src/AppInstallerCommonCore/Filesystem.cpp @@ -152,7 +152,7 @@ namespace AppInstaller::Filesystem #endif try { - std::filesystem::create_symlink(target.weakly_canonical(), link); + std::filesystem::create_symlink(std::filesystem::weakly_canonical(target), link); return true; } catch (std::filesystem::filesystem_error& error) From 662d0a4261584786e55606f89f1de584837e91b9 Mon Sep 17 00:00:00 2001 From: Kaleb Luedtke Date: Fri, 30 Sep 2022 16:36:58 -0500 Subject: [PATCH 5/5] Try again --- src/AppInstallerCommonCore/Filesystem.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/AppInstallerCommonCore/Filesystem.cpp b/src/AppInstallerCommonCore/Filesystem.cpp index 56ff615dbd..78ef9917c0 100644 --- a/src/AppInstallerCommonCore/Filesystem.cpp +++ b/src/AppInstallerCommonCore/Filesystem.cpp @@ -152,7 +152,7 @@ namespace AppInstaller::Filesystem #endif try { - std::filesystem::create_symlink(std::filesystem::weakly_canonical(target), link); + std::filesystem::create_symlink(target, link); return true; } catch (std::filesystem::filesystem_error& error) @@ -171,7 +171,7 @@ namespace AppInstaller::Filesystem bool VerifySymlink(const std::filesystem::path& symlink, const std::filesystem::path& target) { const std::filesystem::path& symlinkTargetPath = std::filesystem::weakly_canonical(symlink); - return symlinkTargetPath == target; + return symlinkTargetPath == std::filesystem::weakly_canonical(target); } void AppendExtension(std::filesystem::path& target, const std::string& value)