You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Metadata accepts empty BytesIO/file values although empty is not allowed #422
Metadata.get_binary_from() (src/zimscraperlib/zim/metadata.py) checks the input object instead of the bytes it read:
ifnotself.empty_allowedandnotvalue: # value is the BytesIO / file objectraiseValueError("Missing value (empty not allowed)")
returnbvalue
io.BytesIO and file objects are always truthy, so an empty stream passes the check and an empty metadata entry ends up in the ZIM, while the same empty value given as bytes is rejected:
An empty file opened with "rb" is accepted the same way.
Expected: empty streams are rejected like empty bytes. Checking bvalue instead of value fixes it; I have that change with two regression tests (BytesIO and file) ready and can open a PR if that works for you.
Activity