SharpZipLib icon indicating copy to clipboard operation
SharpZipLib copied to clipboard

TarEntry does not support absolute paths

Open iUnknwn opened this issue 5 years ago • 2 comments

Currently, TarEntry.cs, in GetFileTarHeader, trims all leading forward slashes.

Trying to write /home/username/foo.txt as an entry would to write home/username/foo.txt

This prevents writing absolute paths to the archive, and also breaks the RootPath string, as the entry name will no longer have the root path as a sub string (if it was set to /home/username), so it will never match when the entry is added to the archive.

If we're trying to specifically avoid UNC path names, it might be easier to just test for a leading double back slash in the original path (instead of testing for leading slashes).

Expected behavior

RootPath should work as expected when adding absolute paths on POSIX.

Actual behavior

RootPath does not work as expected - file strings will never match RootPath because RootPath will still contain the leading '/', but the file entry will not.

Additionally, absolute file paths will be broken, regardless if root path is used.

Version of SharpZipLib

1.1.0

Obtained from (only keep the relevant lines)

  • Package installed using NuGet

iUnknwn avatar Apr 13 '19 02:04 iUnknwn

Couldn't you just set the RootPath to "home/username"?

piksel avatar Feb 01 '20 17:02 piksel

This is probably a duplicate of #38 (how fitting). But that one only contains dead links and not a clear description. Closing it in favor of this one.

piksel avatar Nov 22 '20 15:11 piksel