Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- `scp_alias_hosts` fuzzy rule canonicalising the SCP wiki's alias hosts (`scpwiki.com`, `www.scpwiki.com`, `www.scp-wiki.net`) onto `scp-wiki.wikidot.com` ; all of them serve the same wiki with HTTP 200 rather than a redirect, so without it the same article lands at several ZIM paths and cross-host links resolve to nothing (#423, openzim/zim-requests#402)

### Fixed

- `Metadata` (and `CustomMetadata`/`XCustomMetadata`) now rejects an empty `io.BytesIO` or file-like value when empty is not allowed, like it already did for empty `bytes`

## [5.6.0] - 2026-11-20

### Added
Expand Down
2 changes: 1 addition & 1 deletion src/zimscraperlib/zim/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def get_binary_from(
bvalue = value.read()
if isinstance(value, SupportsSeekableRead) and value.seekable():
value.seek(last_pos)
if not self.empty_allowed and not value:
if not self.empty_allowed and not bvalue:
raise ValueError("Missing value (empty not allowed)")
return bvalue

Expand Down
15 changes: 15 additions & 0 deletions tests/zim/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,21 @@ def test_blank_metadata():
metadata.Metadata(name="Blank", value=b"")


def test_blank_metadata_from_bytesio():
with pytest.raises(ValueError, match=r"Missing value \(empty not allowed\)"):
metadata.Metadata(name="Blank", value=io.BytesIO(b""))


def test_blank_metadata_from_file(tmp_path: pathlib.Path):
fpath = tmp_path / "empty"
fpath.write_bytes(b"")
with (
open(fpath, "rb") as fh,
pytest.raises(ValueError, match=r"Missing value \(empty not allowed\)"),
):
metadata.Metadata(name="Blank", value=fh)


class MetadataInitConfig(NamedTuple):
a_type: type
nb_args: int
Expand Down