You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ZIP/TAR entries with leading path separator are missing #791
I've encountered a zip file that has its filename include a leading path separator / which are missing when you try to iterate through the sub_file_entries of the root file path.
It looks like dfvfs explicitly assumes sub file entries do not include a path separator, which explains why they are missing: https://github.com/log2timeline/dfvfs/blob/main/dfvfs/vfs/zip_directory.py#L23
However, while it might be formally incorrect, there is nothing stopping someone from creating a zip file with leading path separators (like using arcname in zipfile). DFVFS should handle both scenarios for filenames with and without the lead path separator.
importzipfilefromdfvfs.resolverimportresolverfromdfvfs.pathimportzip_path_spec, os_path_specinput_path="test.zip"withzipfile.ZipFile(input_path, "w") aszf:
zf.writestr("/missing.txt", b"data")
zf.writestr("not_missing.txt", b"data")
path_spec=zip_path_spec.ZipPathSpec(location="/", parent=os_path_spec.OSPathSpec(location=input_path))
file_entry=resolver.Resolver().OpenFileEntry(path_spec)
forentryinfile_entry.sub_file_entries:
print(entry.path_spec.comparable) # only prints not_missing.txt
Thx for flagging, I'll take a closer look when time permits which might take a while given eventually I would like to have a more "forensic sound" ZIP processing solution
No worries. I have patched a fix for my own use case in the meantime.
Basically ensured all locations doing location[1:] also tried with just location.
Speaking of Zip support, another bug I ran into (and forgot to report, sorry about that) was an issue where a directory entry would not be properly seen as a directory, even though it was.
The hotfix I had to implement was the following:
if (file_entry.TYPE_INDICATOR==dfvfs_definitions.TYPE_INDICATOR_ZIPandnotfile_entry.IsDirectory()
andfile_entry.GetZipInfo().is_dir()
):
file_entry.entry_type=dfvfs_definitions.FILE_ENTRY_TYPE_DIRECTORY
This was a change I did back in 2022. Unsure if this is still an issue.
changed the title [-]Zip entries with leading path separator are missing.[/-][+]ZIP/TAR entries with leading path separator are missing[/+]on Feb 12, 2026
Speaking of Zip support, another bug I ran into (and forgot to report, sorry about that) was an issue where a directory entry would not be properly seen as a directory, even though it was.
I was not able to reproduce this. So if you have/can reproduce the scenario that could be beneficial.
Although per https://docs.python.org/3/library/zipfile.html on is_dir() This uses the entry’s name: directories should always end with /. Looks like is_dir() is based on naming convention, wondering if there are edge cases.
Activity
joachimmetz commentedon Feb 10, 2026
Thx for flagging, I'll take a closer look when time permits which might take a while given eventually I would like to have a more "forensic sound" ZIP processing solution
jpsnyder commentedon Feb 10, 2026
No worries. I have patched a fix for my own use case in the meantime.
Basically ensured all locations doing
location[1:]also tried with justlocation.jpsnyder commentedon Feb 11, 2026
Speaking of Zip support, another bug I ran into (and forgot to report, sorry about that) was an issue where a directory entry would not be properly seen as a directory, even though it was.
The hotfix I had to implement was the following:
This was a change I did back in 2022. Unsure if this is still an issue.
[-]Zip entries with leading path separator are missing.[/-][+]ZIP/TAR entries with leading path separator are missing[/+]joachimmetz commentedon Jul 15, 2026
I was not able to reproduce this. So if you have/can reproduce the scenario that could be beneficial.
Although per https://docs.python.org/3/library/zipfile.html on is_dir()
This uses the entry’s name: directories should always end with /.Looks like is_dir() is based on naming convention, wondering if there are edge cases.joachimmetz commentedon Jul 15, 2026
Regarding leading separator. Apparently a single ZIP archive file can even contain both absolute and relative paths. Changes in #819