Repository navigation
fix: keep the file a package was decoded from - #1205
Merged
Merged
Conversation
`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
force-pushed
the
fix/decoded-file-source
branch
from
October 10, 2026 11:44
4816651 to
b4b6cef
Compare
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.
🤖 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 theirfile()returned{}. Sofile().name()threwNullPointerError.The wasm binding reads
fileNamethrough that call, soDocument.fileNamethrew for every odt, ods, odp, docx, xlsx, pptx, doc, xls, ppt and iWork document, also with anamepassed toopen, and for every document thatodr.createmade.index.d.tssays it returns the name passed toopen, or an empty string. Found on opendocument.app with 7.5.1. pdf, csv, txt and md were not affected.Fix
OpenDocumentFile,OfficeOpenXmlFile,IworkFileandLegacyMicrosoftFiletake the source file as an optional last constructor argument, andfile()returns it.open_strategypasses the opened file on every decode path:open_file_asandopen_by_cascade. The type probes inlist_file_typesdo not pass it, because nothing reads their file.decryptcopies 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 thatcreate_documentmakes, it opens named bytes through the cascade and throughDecodeOptions::as, then checksfile().name()andfile().size().File.a_decoded_file_on_disk_keeps_its_name: the engines thatcreate_documentcannot make: an encrypted docx (ooxml in a compound file), doc and pages, through both paths.smoke.test.mjs:fileNameon 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).