-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a imghdr_strict
option to .what()
to deliver the same false positives
#81
Conversation
imghdr_strict
option to what()
to deliver the same false positivesimghdr_strict
option to .what()
to deliver the same false positives
Sounds good, at least folks using |
When you think a pull request is useful and is ready to be merged, please consider giving it a positive review. Every check mark ✔️ at the top right of this page gives project maintainers confidence that the proposed changes have been read through and deemed both useful and safe to merge into the codebase. Anyone can review a pull request on GitHub. To do so here:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, the notes regarding matching imghdr will be helpful to newcomers.
if h and imghdr_strict and (ext := imghdr_bug_for_bug.get(h)): | ||
return ext |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this bug only exist when sending in those exact bytes, or also when those bytes are in part of a file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be that the non-passing tests are down to PureMagic's mostly superior matching rules. This should be in relation to my comment where @cclauss was testing dummy strings against the database and getting fails or no returned data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My tests come from reading the test_xxx()
functions in https://github.com/python/cpython/blob/3.12/Lib/imghdr.py ? They are very byte-by-byte tests so are quite specific. If you think there are other positives to add to our tests, they are easy to add.
- Adding #72 #75 #76 #81 `.what()` to be a drop in replacement for `imghdr.what()` (thanks to Christian Clauss and Andy - NebularNerd) - Adding #67 Test on Python 3.13 beta (thanks to Christian Clauss) - Adding #77 from __future__ import annotations (thanks to Christian Clauss - Fixing #66 Confidence sorting (thanks to Andy - NebularNerd) --------- Co-authored-by: Andy <[email protected]> Co-authored-by: Christian Clauss <[email protected]>
@NebularNerd Your review, please.