mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-04 05:25:00 +00:00
optional smarter readerfactory testing through readeroptions adding an extension or ArchiveType for hinting? #701
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @mitchcapper on GitHub (Sep 11, 2025).
Right now factories are just bruteforced in order when detecting an unknown stream. While things can have the wrong extension or the user may not know the extension I would assume a good bit of time the user does have the filename.
The user could optionally provide this for hinting. We already maintain a list of supported extensions for external use ( IFactory.GetSupportedExtensions ) that we could then make use of internally. This would be largely backwards compatible as we would simply switch which factory we try first to be the suspected factory, if that fails the normal bruting of the other factories would be used. Things like TarFactory could use the ReaderOptions extension to even decide what compression algorithm to try first (although that would require adding an internal table of extension to compression alg as I don't think we maintain that data anywhere).
If this sounds sane I can do a PR.
@adamhathcock commented on GitHub (Sep 15, 2025):
It's sane but it's a convenience thing. I'm happy to accept PRs but generally don't do them myself as I just thought others would do their own as this is a low level library. There have been vulnerabilities related to the extras (like creating directories) instead of the core of the library.
That said, I'm happy to accept PRs about anything really.