Skip to content

fix: keep the file a package was decoded from - #1205

Merged
andiwand merged 2 commits into
mainfrom
fix/decoded-file-source
Oct 10, 2026
Merged

andiwand merged 2 commits into
mainfrom
fix/decoded-file-source

Conversation

@andiwand

@andiwand andiwand commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

🤖 Generated with Claude Code

Problem

DecodedFile::file() returned an empty handle for every odf, ooxml, iWork and legacy Office file. These four engines read through an archive filesystem, and their file() returned {}. So file().name() threw NullPointerError.

The wasm binding reads fileName through that call, so Document.fileName threw for every odt, ods, odp, docx, xlsx, pptx, doc, xls, ppt and iWork document, also with a name passed to open, and for every document that odr.create made. index.d.ts says it returns the name passed to open, or an empty string. Found on opendocument.app with 7.5.1. pdf, csv, txt and md were not affected.

Fix

  • OpenDocumentFile, OfficeOpenXmlFile, IworkFile and LegacyMicrosoftFile take the source file as an optional last constructor argument, and file() returns it.
  • open_strategy passes the opened file on every decode path: open_file_as and open_by_cascade. The type probes in list_file_types do not pass it, because nothing reads their file.
  • decrypt copies the engine, so a decrypted file keeps the source with no other change.

The arguments have defaults, so the tests that build an engine directly need no change.

Tests

  • File.a_decoded_package_keeps_the_file_it_was_read_from: for each type that create_document makes, it opens named bytes through the cascade and through DecodeOptions::as, then checks file().name() and file().size().
  • File.a_decoded_file_on_disk_keeps_its_name: the engines that create_document cannot make: an encrypted docx (ooxml in a compound file), doc and pages, through both paths.
  • wasm smoke.test.mjs: fileName on a named and an unnamed package, and on a created odt and xlsx.

The full native suite passes (2476 passed, 6 skipped as usual, after the rebase), and the wasm node suite passes (67).

andiwand and others added 2 commits October 10, 2026 13:39
`DecodedFile::file()` returned an empty handle for every odf, ooxml,
iWork and legacy Office file, because these engines read through an
archive and did not keep the file. So `file().name()` threw
`NullPointerError`, and so did `fileName` in npm for every such
document, also one that `odr.create` made.

Each of the four engines takes the source file as an optional last
argument and returns it from `file()`. `open_strategy` passes the file it
opened on every decode path. The type probes in `list_file_types` do not,
because nothing reads their file. A decrypted file copies the engine, so
it keeps the source too.

Tests: `File.a_decoded_package_keeps_the_file_it_was_read_from` and
`File.a_decoded_file_on_disk_keeps_its_name` cover odf, ooxml in a zip and
in a compound file, legacy Office and iWork, through the cascade and
through `DecodeOptions::as`. A wasm smoke test checks `fileName` on a
named and an unnamed package and on a created document. The full native
suite passes (2463, 6 skipped), and the wasm suite passes (67).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Sj1iUVrs9nGWVk2j1LpVK1
`a_decoded_package_keeps_the_file_it_was_read_from` already covers odf
and ooxml in a zip through both decode paths, because create_document
makes odt, ods, docx and xlsx. The disk test now checks only ooxml in a
compound file, legacy Office and iWork.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LkhPXqd9UFL99dDDkMDKQN
@andiwand
andiwand force-pushed the fix/decoded-file-source branch from 4816651 to b4b6cef Compare October 10, 2026 11:44
@andiwand
andiwand merged commit 44f5799 into main Oct 10, 2026
17 checks passed
@andiwand
andiwand deleted the fix/decoded-file-source branch October 10, 2026 11:45
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