Skip to content

Commit

Permalink
path trim
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinJump committed Jun 15, 2024
1 parent b72b76f commit d52e7ae
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions uSync.BackOffice/Services/uSyncService_Files.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand All @@ -61,9 +63,10 @@ public void DeCompressFile(string zipArchive, string target)
if (entry.Length == 0) continue;

var filePath = GetOSDependentPath(entry.FullName);

var destination = Path.GetFullPath(Path.Combine(resolvedTarget, filePath));
if (destination.StartsWith(resolvedTarget) is false)
throw new Exception("Invalid file path");
if (!destination.StartsWith(fullTarget))
throw new InvalidOperationException("Invalid file path");

var destinationFolder = Path.GetDirectoryName(destination);

Expand Down

0 comments on commit d52e7ae

Please sign in to comment.