Skip to content

Commit

Permalink
Fix icsharpcode#337 and partially icsharpcode#338
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
iUnknwn committed Apr 13, 2019
1 parent afcccb0 commit d4c79f2
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/ICSharpCode.SharpZipLib/Tar/TarEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 == '\\')
Expand All @@ -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;

Expand Down

0 comments on commit d4c79f2

Please sign in to comment.