Skip to content

fix(zip): read an entry name with a leading slash as relative - #862

Merged
andiwand merged 1 commit into
mainfrom
fix/zip-absolute-entry-name
Sep 8, 2026
Merged

fix(zip): read an entry name with a leading slash as relative#862
andiwand merged 1 commit into
mainfrom
fix/zip-absolute-entry-name

Conversation

@andiwand

@andiwand andiwand commented Sep 8, 2026

Copy link
Copy Markdown
Member

🤖 Generated with Claude Code

A reported .odt did not open: its zip carries the odf manifest's root entry
(manifest:full-path="/") as a real zip entry named /, holding a second copy
of content.xml's bytes. zip::Archive::Entry::path() built a RelPath from
that name and threw not a relative path, so the file failed before any
decoding began. LibreOffice refuses the file too — removing that one entry is
what makes soffice --convert-to load it.

APPNOTE.TXT 4.4.17.1 says an entry name is always relative to the archive root,
so a leading slash is malformed and the tolerant read is to drop it. The name
now goes through Path(...).make_relative(), and a name that is nothing but
the root normalises to the empty path, which addresses no entry — ZipArchive
skips it.

Nothing else in the corpus moves: a well-formed name is unchanged by
make_relative(), and any input that did carry an absolute name would have
thrown before, so none is in there.

The rendered text of the new fixture matches LibreOffice's .txt export of the
same file with the stray entry removed, character for character.

Test data

@andiwand
andiwand force-pushed the fix/zip-absolute-entry-name branch from c5deb67 to 5649601 Compare September 8, 2026 18:23
APPNOTE.TXT 4.4.17.1 makes an entry name relative to the archive root, so a
leading slash is read away and a name that is nothing but the root, addressing
no entry, is dropped.

The reported `.odt` carries the odf manifest's root entry as a real zip entry
named "/", which threw before and which LibreOffice refuses too.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WR6c2WEdi9553WjWmbxZka
@andiwand
andiwand force-pushed the fix/zip-absolute-entry-name branch from 5649601 to 393fb0b Compare September 8, 2026 18:25
@andiwand
andiwand merged commit 19c51a1 into main Sep 8, 2026
14 checks passed
@andiwand
andiwand deleted the fix/zip-absolute-entry-name branch September 8, 2026 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant