Repository navigation
Reject empty stream values in binary Metadata - #425
Open
playlikeboy wants to merge 2 commits into
Open
playlikeboy wants to merge 2 commits into
playlikeboy wants to merge 2 commits into
Conversation
Metadata.get_binary_from() checked the original value for emptiness instead of the bytes it read from it. An io.BytesIO or file object is always truthy, so an empty stream passed the "empty not allowed" check and an empty metadata entry ended up in the ZIM, while an empty bytes value was correctly rejected. Check the read bytes instead.
…-streams # Conflicts: # CHANGELOG.md
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #422
Metadatarejected an emptybytesvalue when empty values are not allowed, but an emptyio.BytesIO(or other file-like value) passed the check. The check rannot valueon the original value, and a stream object is always truthy. It now checks the bytes read from the value (bvalue), so both forms are handled the same way.Changes:
src/zimscraperlib/zim/metadata.py: test emptiness onbvalueinstead ofvalue.tests/zim/test_metadata.py: two tests, one with an emptyio.BytesIOand one with an empty file-like object, both now raisingValueError; metadata that allows empty values is unaffected.CHANGELOG.md: entry under Unreleased / Fixed.pytest tests/zim/test_metadata.py: 193 passed. In the fulltests/zimrun,test_start_logs_metadata_log_contents[tags0]fails locally onmainas well, so it is unrelated to this change.