Accept application/zip for OOXML content detection#2
Merged
Conversation
`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.
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.
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