You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tika.apache.org by "tballison (via GitHub)" <gi...@apache.org> on 2026/10/06 21:30:36 UTC
[PR] TIKA-4937: detection follow-ups from the ICOParser review [tika]
tballison opened a new pull request, #3303:
URL: https://github.com/apache/tika/pull/3303
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
Thanks for your contribution to [Apache Tika](https://tika.apache.org/)! Your help is appreciated!
Before opening the pull request, please verify that
* there is an open issue on the [Tika issue tracker](https://issues.apache.org/jira/projects/TIKA) which describes the problem or the improvement. We cannot accept pull requests without an issue because the change wouldn't be listed in the release notes.
* the issue ID (`TIKA-XXXX`)
- is referenced in the title of the pull request
- and placed in front of your commit messages surrounded by square brackets (`[TIKA-XXXX] Issue or pull request title`)
* commits are squashed into a single one (or few commits for larger changes)
* Tika builds and unit tests pass with `./mvnw clean install` (`clean test` alone cannot resolve the pipes plugin zips)
* if you used a generative AI tool: follow the [ASF Generative Tooling Guidance](https://www.apache.org/legal/generative-tooling.html) (`Generated-by: <tool>` in the commit message), and consider running the pre-flight in `.skills/devs/pr-review/SKILL.md` — fix what it finds; don't paste its report here
* there should be no conflicts when merging the pull request branch into the *recent* `main` branch. If there are conflicts, please try to rebase the pull request branch on top of a freshly pulled `main` branch
* if you add new module that downstream users will depend upon add it to relevant group in `tika-bom/pom.xml`.
We will be able to faster integrate your pull request if these conditions are met. If you have any questions how to fix your problem or about using Tika in general, please sign up for the [Tika mailing list](http://tika.apache.org/mail-lists.html). Thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@tika.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] TIKA-4937: detection follow-ups from the ICOParser review [tika]
Posted by "dschmidt (via GitHub)" <gi...@apache.org>.
dschmidt commented on PR #3303:
URL: https://github.com/apache/tika/pull/3303#issuecomment-6030005988
My 🤖 says:
The OS/2 part is good. The TGA part has one regression: with TGA down at priority 50, the cursor magic (`00 00 02 00`, byte 5 zero) claims every type 2 TGA without an image id that the new TGA rule rejects. A plain 24 bpp TGA only stays TGA through the clause-length tie-break.
Detection with the `tika-mimetypes.xml` of main and of cfe814a6fa, synthetic headers followed by pixel data:
| Input (hex) | main | this PR |
|---|---|---|
| type 2, 15 bpp: `00 00 02 00 00 00 00 00 00 00 00 00 04 00 04 00 0F 00` | `image/x-tga` | `image/x-win-bitmap`, also when named `x.tga` |
| the same with a 3 byte image id (`03 00 02 ...`) | `image/x-tga` | `application/octet-stream` |
| type 2, 24 bpp, colour map entry size set but no map: `00 00 02 00 00 00 00 18 00 00 00 00 04 00 04 00 18 00` | `image/x-tga` | `image/x-win-bitmap`, also when named `x.tga` |
| `41 01 01 99 99 99 99 20` plus anything | `application/octet-stream` | `image/x-tga` |
Suggested changes in `tika-mimetypes.xml`. The first two were tried against the samples above plus `testCUR.cur` and `testICO.ico`:
1. `image/x-tga`: add `<match value="\017" type="string" offset="16"/>` to the type 2 and type 10 rules. Fixes rows 1 and 2.
2. `image/x-win-bitmap`: require at least one image by replacing the nested `offset="5"` match with `<match value="[\\x01-\\xff]\\x00" type="regex" offset="4"/>`. A TGA without a colour map has zeros there, so the overlap is gone instead of resting on the tie-break. Row 3 is then `application/octet-stream` by content and `image/x-tga` by name. Cursors with 1 to 255 images are unaffected.
3. Not tried: the colour-mapped rules (types 1 and 9) pin only three bytes (row 4). Checking the pixel depth at 16 as well, as the XML comment says, would tighten them.
`MimeDetectionTest`:
- The cursor and Lotus assertions in `testTgaDetection` pass on main too (bytes 1 to 4 are `00 02 00 01` and `00 02 00 04`, which neither the old nor the new rule matches), so nothing pins the priority change. Better: a 15 bpp type 2 header is `image/x-tga`, and a cursor header with 256 images (`00 00 02 00 00 01`) is not.
- `header[5] = (byte) 256` is 0.
- Three comments describe the old rules ("used to match", "the old rules accepted", "the old rule matched"), which the development skill asks to avoid.
Smaller points:
- `ICOParser` throws again on `BA` input when it is called directly, or for an array with a broken tag that is named `.ico`. Fine if intended, but CHANGES does not say so.
- `image/x-os2-graphics` is not in `InferenceLoader.NON_RASTER`, where the icon type these files used to be detected as is.
- CHANGES: the RLE types 9, 10 and 11 are newly detected, which is worth a word, and the lost content detection could carry a "Compat:" note.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@tika.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] TIKA-4937: detection follow-ups from the ICOParser review [tika]
Posted by "tballison (via GitHub)" <gi...@apache.org>.
tballison merged PR #3303:
URL: https://github.com/apache/tika/pull/3303
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@tika.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] TIKA-4937: detection follow-ups from the ICOParser review [tika]
Posted by "tballison (via GitHub)" <gi...@apache.org>.
tballison commented on PR #3303:
URL: https://github.com/apache/tika/pull/3303#issuecomment-6025826196
@dschmidt can you have your :robot: look at this :robot: 's work? :rofl:
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@tika.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] TIKA-4937: detection follow-ups from the ICOParser review [tika]
Posted by "tballison (via GitHub)" <gi...@apache.org>.
tballison commented on PR #3303:
URL: https://github.com/apache/tika/pull/3303#issuecomment-6043995154
Thank you @dschmidt !
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@tika.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org