Skip to content

Accept application/zip for OOXML content detection#2

Merged
mhsdef merged 1 commit into
mainfrom
fix/accept-zip-for-ooxml-content-detection
May 7, 2026
Merged

Accept application/zip for OOXML content detection#2
mhsdef merged 1 commit into
mainfrom
fix/accept-zip-for-ooxml-content-detection

Conversation

@mhsdef

@mhsdef mhsdef commented May 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Validator was rejecting otherwise-valid docx/xlsx/pptx files generated by tooling that writes `_rels/.rels` before `[Content_Types].xml` inside the zip (e.g. python-docx, which Dozer's draftsman uses). `infer` only reports the specific OOXML mime when `[Content_Types].xml` is the first entry — otherwise it falls back to `application/zip`, which the validator's allowlist didn't include.

This change adds `application/zip` to the supported-mime list and treats it as compatible with any allowed OOXML extension. Random zips renamed to `.docx` still fail at the LibreOffice load step (which returns 500), so we don't lose the practical defense.

Test plan

  • Added `tests/fixtures/test_document_rels_first.docx` — a re-pack of the existing `test_document.docx` with `_rels/.rels` first to mimic python-docx output.
  • Added `test_docx_with_nonstandard_zip_ordering` — RED before the validator change (status 400 from `is_compatible_type`), GREEN after.
  • Verified end-to-end against a real Dozer draftsman template (`payoff_letter.docx`) hitting the locally-running runtime container: previously 400, now 200 with a valid 1-page PDF.
  • Full suite still green in the `tester` Docker stage (17/17).

`infer` only reports the OOXML mime when the zip's first entry is
[Content_Types].xml. Tooling like python-docx writes _rels/.rels first,
so the validator was rejecting otherwise-valid docx/xlsx/pptx with
"Unknown or unsupported file type" before LibreOffice ever saw them.

Allow application/zip through `is_supported_mime`, and treat it as
compatible with any supported OOXML extension. Random zips renamed to
.docx still fail at the LibreOffice load step.

Added tests/fixtures/test_document_rels_first.docx (a re-pack of the
existing test_document.docx with _rels/.rels first) and a regression
test that converts it end-to-end.
@mhsdef mhsdef self-assigned this May 7, 2026
@mhsdef mhsdef merged commit 6189105 into main May 7, 2026
3 checks passed
@mhsdef mhsdef deleted the fix/accept-zip-for-ooxml-content-detection branch May 7, 2026 12: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