guzba / zippy

Pure Nim implementation of deflate, zlib, gzip and zip.
MIT License
246 stars 29 forks source link

Handle entries ending with / as directories #48

Closed nnsee closed 1 year ago

nnsee commented 1 year ago

Currently, zip files with entries where neither the DOS nor the Unix directory flag is set, but are in reality directories (as indicated by paths ending with /) fail to be extracted, as the directories are erroneously identified as FileRecord. Such a zip file can be found here, for example: https://github.com/odin-lang/Odin/releases/download/dev-2022-08/odin-ubuntu-amd64-dev-2022-08.zip

This PR adds an extra check for such entries - if the filename ends with /, assume it is a DirectoryRecord.

guzba commented 1 year ago

Thanks for reporting this. I did find that it appears miniz is also doing the / check: https://github.com/richgel999/miniz/blob/be92575500f71dfb5ac7b0c5bb47b6e736c23039/miniz_zip.c#L1182

So while I can't be sure if this causes more issues than it fixes, it makes sense to me and there is evidence the check is done more widely so lets give it a go.