From 1544a32c97fd01398408f61d631e2583a2bc798b Mon Sep 17 00:00:00 2001 From: Kevin Jump Date: Sat, 15 Jun 2024 21:12:16 +0100 Subject: [PATCH] us ! in place of is false to past test. --- uSync.BackOffice/Services/uSyncService_Files.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/uSync.BackOffice/Services/uSyncService_Files.cs b/uSync.BackOffice/Services/uSyncService_Files.cs index 5fc1eb98..28be7c4a 100644 --- a/uSync.BackOffice/Services/uSyncService_Files.cs +++ b/uSync.BackOffice/Services/uSyncService_Files.cs @@ -50,6 +50,8 @@ public void DeCompressFile(string zipArchive, string target) var resolvedTarget = _syncFileService.GetAbsPath(target); + var fullTarget = Path.GetFullPath(resolvedTarget); + using (var zip = ZipFile.OpenRead(zipArchive)) { if (!zip.Entries.Any(x => x.FullName.EndsWith(_uSyncConfig.Settings.DefaultExtension))) @@ -63,8 +65,8 @@ public void DeCompressFile(string zipArchive, string target) var filePath = GetOSDependentPath(entry.FullName); var destination = Path.GetFullPath(Path.Combine(resolvedTarget, filePath)); - if (destination.StartsWith(resolvedTarget) is false) - throw new ArgumentException($"Path {destination} is not in {resolvedTarget}"); + if (!destination.StartsWith(fullTarget)) + throw new InvalidOperationException("Invalid file path"); var destinationFolder = Path.GetDirectoryName(destination);