Skip to content

TIKA-5031: Parse 3MF packages as zip, not XML - #3529

Merged
tballison merged 2 commits into
apache:mainfrom
dschmidt:TIKA-5031-3mf-zip
Nov 4, 2026
Merged

tballison merged 2 commits into
apache:mainfrom
dschmidt:TIKA-5031-3mf-zip

Conversation

@dschmidt

@dschmidt dschmidt commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

.3mf files are detected as application/vnd.ms-package.3dmanufacturing-3dmodel+xml (TIKA-4224). Without a declared supertype, the +xml suffix made that a sub-type of application/xml, so XMLParser received the zip package and failed; /unpack/preset/thumbnail answered 422.

  • tika-mimetypes.xml: the type is declared a sub-type of application/zip, which takes precedence over the suffix rule, so ZipParser opens the package.
  • ZipParser: the type is added to the zip specializations whose content type it keeps, instead of overwriting it with application/zip.
  • OPCPackageDetector: [Content_Types].xml maps the 3MF model content type, so the streaming zip detector returns 3MF instead of x-tika-ooxml. TestContainerAwareDetector.test3MF only checks the streaming detector for zip sub-types, which is why this did not show before.

Test: test3mf.3mf keeps its type, has no container exception and its parts come out as embedded documents. Also checked against the 3MF Consortium's sample files: 37 of 40 answered 422 before and parse now; three were detected as plain zip before and are now detected as 3MF.

Open question: the +xml type names the model part inside the package; IANA registers the package itself as model/3mf. Renaming would change the detected type for existing users, so this PR keeps the name.

Follow-up once this and #3530 are merged: the 3MF thumbnail. It should follow the package's thumbnail relationship in _rels/.rels (http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail), as 3MF is an OPC package, rather than assume the usual /Metadata/thumbnail.png.

https://issues.apache.org/jira/browse/TIKA-5031

@tballison

Copy link
Copy Markdown
Contributor

I think we should do a breaking change to fix the mime type on a follow on ticket? What we have is a bug and we should fix it. wdyt?

@dschmidt

dschmidt commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Not sure, what do you mean?
What would you like in this PR and what in a followup?

@tballison

Copy link
Copy Markdown
Contributor

This is good as is. I'll merge when green.

@dschmidt

dschmidt commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

You mean the mime type is weird and we should change that? Of course, no objections. Are you taking care?

@tballison
tballison merged commit 749d2f1 into apache:main Nov 4, 2026
4 checks passed
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.

2 participants