Skip to content

TarEntry does not support absolute paths #338

@iUnknwn

Description

@iUnknwn

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementFeature request or other improvements of existing functionalitytarRelated to TAR file format

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions