neilharvey / FileSignatures

A small library for detecting the type of a file based on header signature (also known as magic number).
MIT License
250 stars 41 forks source link

Fixes #66 handle pdf specs #67

Closed MaximeLaffaire closed 3 months ago

MaximeLaffaire commented 3 months ago

As described in #66 , some specs were missing from the PDF detection :

Since I override the base implementation of FileFormat.IsMatch, I added some unit tests to cover that. I also chose to not call base.IsMatch in the overriden method, it felt redundant and unoptimized 🤔

Also, I added two tests on real pdf files, you can check the headers by opening the files with a hex editor like Hex Fiend

neilharvey commented 3 months ago

Thanks, looks good - I'll merge the PR and push a new release when I get a chance. Cheers!