file-type icon indicating copy to clipboard operation
file-type copied to clipboard

Add support for zlib

Open dr-peppe opened this issue 3 years ago • 2 comments
trafficstars

Adding support for zlib compressed files. Currently I've added the magic numbers using "no preset dictionary" as they seem to be the ones used in practice.

I used these as references for the magic numbers: https://en.wikipedia.org/wiki/List_of_file_signatures https://stackoverflow.com/questions/9050260/what-does-a-zlib-header-look-like https://datatracker.ietf.org/doc/html/rfc6713 https://datatracker.ietf.org/doc/html/rfc1950

I did notice a conflict with the magic bytes used for the dmg format. After some investigation I think it's using incorrect detection. E.g. when looking at https://en.wikipedia.org/wiki/List_of_file_signatures it's clear that the format signature is at the end of such files (end–512) which seems to match some of my local dmg files as well. I think this should be resolved in a separate issue.

dr-peppe avatar Mar 15 '22 07:03 dr-peppe

@dr-peppe Bump :)

sindresorhus avatar May 27 '22 09:05 sindresorhus

@dr-peppe Bump :)

Sorry, I kind of forgot this as we implemented the check above as a preprocessing step for our zlib purposes for now, doing that check first before falling back to file-type for other file types. But would be nice to get rid of that and just rely on file-type of course :)

I had some problems creating files for test purposes with these other documented variations, but after looking at the Zlib API in later versions of Node I think it might be possible. I need to look into this.

dr-peppe avatar Jun 21 '22 06:06 dr-peppe

@dr-peppe Still interested or should I close this?

sindresorhus avatar Dec 10 '22 20:12 sindresorhus