From 466b6f88cacb4e94db7a0b13a2b979ef74edf5d5 Mon Sep 17 00:00:00 2001 From: "Sean Zimmermann (SURFACE)" Date: Fri, 12 Apr 2019 20:11:56 -0700 Subject: [PATCH] Fix icsharpcode/SharpZipLib#337 and partially #338 For #337: removes the changes to path based on current working directory. This prevents issues where files that are below the current working directly will behave differently than those that aren't. For #338: Simply removes the code that would remove leading forward slashes from paths. This should unbreak absolute POSIX paths, and avoid the issue where RootPath wouldn't work, though it does allow unc paths (which were previously blocked) as a potential side effect. Part of the issue with #338 is any changes to the path, as part of the TarEntry's GetFileTarHeader have the potential to break RootPath, so you can't simply check for UNC path names there and modify. --- src/ICSharpCode.SharpZipLib/Tar/TarEntry.cs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/ICSharpCode.SharpZipLib/Tar/TarEntry.cs b/src/ICSharpCode.SharpZipLib/Tar/TarEntry.cs index f7d2a493d..8f665fc61 100644 --- a/src/ICSharpCode.SharpZipLib/Tar/TarEntry.cs +++ b/src/ICSharpCode.SharpZipLib/Tar/TarEntry.cs @@ -379,10 +379,14 @@ public void GetFileTarHeader(TarHeader header, string file) string name = file; // 23-Jan-2004 GnuTar allows device names in path where the name is not local to the current directory + // 04-Apr-2019 Removed this block, as it creates different behavior based the location of the executing + // assembly. + /* if (name.IndexOf(Directory.GetCurrentDirectory(), StringComparison.Ordinal) == 0) { name = name.Substring(Directory.GetCurrentDirectory().Length); } + */ /* if (Path.DirectorySeparatorChar == '\\') @@ -404,14 +408,6 @@ public void GetFileTarHeader(TarHeader header, string file) name = name.Replace(Path.DirectorySeparatorChar, '/'); - // No absolute pathnames - // Windows (and Posix?) paths can start with UNC style "\\NetworkDrive\", - // so we loop on starting /'s. - while (name.StartsWith("/", StringComparison.Ordinal)) - { - name = name.Substring(1); - } - header.LinkName = String.Empty; header.Name = name;