Skip to content

Update Tika MIME data to the 4.0.0 release - #177

Merged
jeremy merged 2 commits into
mainfrom
tika-4
Aug 22, 2026
Merged

Update Tika MIME data to the 4.0.0 release#177
jeremy merged 2 commits into
mainfrom
tika-4

Conversation

@jeremy

@jeremy jeremy commented Aug 22, 2026

Copy link
Copy Markdown
Member

Repins script/download_tika_data.rb from the 2026-05-11 snapshot (c2972478) to the commit the 4.0.0 release tag dereferences to (514e1b3d), regenerates lib/marcel/tables.rb via rake update, and classifies every resulting behavior change.

Classified behavior diff

Upstream's data diff since our pin is confined to five types.

(a) Additive

  • application/vnd.android.axml — new type with working magic (RES_XML_TYPE header 03 00 08 00 + RES_STRING_POOL_TYPE at offset 8). Previously application/octet-stream. Fixture added.
  • application/pdf — a new priority-40 regex fallback for %PDF headers behind long print-job-ticket comment preambles (TIKA-4782). The generator's regex subset can't express it, so it joins the pinned unsupported-rule manifest (59 → 60 rules; sha + warning-line counts updated). PDF detection is unchanged.

Inert (dead before, dead after)

  • application/pkcs7-signature (DER branches), application/pkcs7-mime, application/x-pkcs12 — Tika rebuilt these DER magics on typeless <match value="0x..."> elements. Tika defaults an absent type to string and hex-decodes; our generator only decodes when type="string" is explicit, so both the old rules (five 0x30800x3084 branches) and the new ones generate as inert literal-text matchers. No behavior change either direction. The PEM -----BEGIN PKCS7 branch still works.

(b) The one live flip: application/timestamped-data

The pre-4.0 magic was a working byte match on 30 80 06 0B 2A 86 48 86 F7 (type="string", hex-decoded). The 4.0.0 rewrite nests the OID under a typeless 0x30 parent, which — via the generator gap above — would have silently killed the content detection marcel 2.0 shipped.

data/custom.xml now carries upstream's rule with the match types spelled out: same shape and priority 60, requiring the full id-ct-timestampedData OID (1.2.840.113549.1.9.16.1.31) scanned across the DER length forms (offset="2:6"). Net effect is a correctness fix in both directions, each pinned by a test:

  • definite long-form encodings (30 82 …) are now detected — previously only the indefinite 30 80 form matched;
  • sibling CMS content types in the 1.2.840.113549.1.9.16.1.* arc (compressedData .9, authData .2, …) are no longer misdetected as timestamped-data, which the loose 9-byte prefix allowed. Upstream's own comments confirm the intent: the masked .9.16.1.* magic belongs to pkcs7-mime, with timestamped-data winning only on its exact OID at higher priority.

(c) Canonical names / aliases / extensions

None. The tables diff outside MAGIC is empty.

Verification

  • Full rake green (668 runs), including tables:check and the pinned unsupported-rule manifest.
  • rake update is idempotent — re-running leaves the tree unchanged.
  • New fixtures: timestamped-data in both DER length forms, AXML; new regression test for the CMS-arc false positive.

Follow-up (not this PR)

Teach the generator to decode typeless matches the way Tika does — or count them as unsupported — instead of emitting silent literal-text matchers. That would enliven the CMS/DER magics carried dead in the tables today (~14 entries), each needing individual review.

Review notes

  • The upstream typeless timestamped-data matcher carried in the tables is near-inert rather than fully dead: a file beginning with the literal ASCII text 0x30 and carrying the binary TSD OID within bytes 2–6 would still match. Any such collision necessarily contains the full id-ct-timestampedData OID, so the detection it produces is the same one the live rule gives real TSD files; not worth adding suppression machinery to the generator for. Goes away with the typeless-decode follow-up.
  • The definite-length fixture initially used a non-minimal length encoding (BER, not DER); rebuilt with a >255-byte payload so the 30 82 long form is legitimately required.

jeremy added 2 commits August 22, 2026 12:18
Repin script/download_tika_data.rb from the 2026-05-11 snapshot (c2972478)
to the commit the 4.0.0 tag dereferences to (514e1b3d) and regenerate
lib/marcel/tables.rb with rake update.

Upstream's diff is confined to five types, classified as follows:

* application/vnd.android.axml: new type with working magic (RES_XML_TYPE
  header + string-pool chunk). Additive; previously application/octet-stream.

* application/pdf: a new priority-40 regex fallback for %PDF headers behind
  long print-job-ticket comment preambles (TIKA-4782). The generator's regex
  subset can't express it, so it joins the pinned unsupported-rule manifest
  (59 -> 60 rules, sha and warning-line counts updated in generate_tables.rb
  and generate_tables_test.rb). PDF detection is unchanged.

* application/pkcs7-signature, application/pkcs7-mime, application/x-pkcs12:
  Tika rebuilt these DER magics on typeless <match value="0x...">
  elements. Tika defaults an absent type to "string" and hex-decodes the
  value, but the generator only decodes when type="string" is explicit, so
  both the old rules (five 0x3080-0x3084 branches) and the new ones generate
  as inert literal-text matchers. No behavior change: dead before, dead
  after. The PEM pkcs7-signature branch still works.

* application/timestamped-data: the one live behavior change. The pre-4.0
  magic was a working byte match on 30 80 06 0B 2A 86 48 86 F7; the 4.0.0
  rewrite nests the OID under a typeless 0x30 match, which would have
  silently killed content detection marcel 2.0 shipped. data/custom.xml now
  carries upstream's rule with the match types spelled out: same shape and
  priority, requiring the full id-ct-timestampedData OID (.9.16.1.31) across
  the DER length forms. Net effect is a fix in both directions: definite
  long-form encodings are now detected (previously only indefinite 30 80),
  and sibling CMS content types in the 1.2.840.113549.1.9.16.1.* arc
  (compressedData, authData, ...) are no longer misdetected as
  timestamped-data, which the loose 9-byte prefix allowed.

New fixtures pin timestamped-data (both DER length forms) and AXML
detection, and a regression test pins the CMS false-positive fix.

Follow-up worth its own change: teach the generator to decode typeless
matches the way Tika does (or count them as unsupported) instead of
emitting silent literal-text matchers; that would enliven the CMS/DER
magics carried dead in the tables today.
The fixture encoded a 35-byte body with the two-byte long form (30 82 00 23),
which DER forbids: lengths must use the shortest encoding. Grow the payload
past 255 bytes so the 30 82 header is legitimately required, keeping the OID
at offset 4 that the fixture exists to exercise.
@jeremy
jeremy merged commit fe45c80 into main Aug 22, 2026
20 checks passed
@jeremy
jeremy deleted the tika-4 branch August 22, 2026 19:26
@jeremy jeremy mentioned this pull request Aug 22, 2026
jeremy added a commit that referenced this pull request Aug 22, 2026
Tika 4.0.0 data refresh (#177): new Android binary XML detection is additive,
and the timestamped-data change is a bug fix — correct definite-length DER
detection, no more misidentifying sibling CMS content types. No API, Ruby
requirement, canonical type, alias, or extension changes: minor release.
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