Skip to content

Commit 466b6f8

Browse files
committed
Fix icsharpcode#337 and partially icsharpcode#338
For icsharpcode#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 icsharpcode#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 icsharpcode#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.
1 parent d9f7fc1 commit 466b6f8

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/ICSharpCode.SharpZipLib/Tar/TarEntry.cs

+4-8
Original file line numberDiff line numberDiff line change
@@ -379,10 +379,14 @@ public void GetFileTarHeader(TarHeader header, string file)
379379
string name = file;
380380

381381
// 23-Jan-2004 GnuTar allows device names in path where the name is not local to the current directory
382+
// 04-Apr-2019 Removed this block, as it creates different behavior based the location of the executing
383+
// assembly.
384+
/*
382385
if (name.IndexOf(Directory.GetCurrentDirectory(), StringComparison.Ordinal) == 0)
383386
{
384387
name = name.Substring(Directory.GetCurrentDirectory().Length);
385388
}
389+
*/
386390

387391
/*
388392
if (Path.DirectorySeparatorChar == '\\')
@@ -404,14 +408,6 @@ public void GetFileTarHeader(TarHeader header, string file)
404408

405409
name = name.Replace(Path.DirectorySeparatorChar, '/');
406410

407-
// No absolute pathnames
408-
// Windows (and Posix?) paths can start with UNC style "\\NetworkDrive\",
409-
// so we loop on starting /'s.
410-
while (name.StartsWith("/", StringComparison.Ordinal))
411-
{
412-
name = name.Substring(1);
413-
}
414-
415411
header.LinkName = String.Empty;
416412
header.Name = name;
417413

0 commit comments

Comments
 (0)