[ https://issues.apache.org/jira/browse/TIKA-4098?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17741557#comment-17741557 ]
ASF GitHub Bot commented on TIKA-4098: -------------------------------------- SchwingSK opened a new pull request, #1231: URL: https://github.com/apache/tika/pull/1231 <!-- 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 is successfully built and unit tests pass by running `mvn clean test` * 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! > Detection fails on PDF with garbage before header > ------------------------------------------------- > > Key: TIKA-4098 > URL: https://issues.apache.org/jira/browse/TIKA-4098 > Project: Tika > Issue Type: Bug > Components: core > Affects Versions: 2.8.0 > Reporter: Thierry Guérin > Priority: Minor > Attachments: garbageBeforeHeader.pdf > > > PDF detection fails on files that contain too much garbage before the header > 'PDF%-'. > Those PDFs do not respect the specification, but are nonetheless correctly > handled by PDF viewers. > The joined PDF is an example on the garbage found in a real-life PDF (looks > like email headers that 'leaked' onto the PDF file). The PDF itself is one > that I generated so that the exemple si small. > The current magic for PDFs limits the search for the '%PDF-%' header to 512 > bytes, and in the joined PDF it's located after 702 garbage bytes. > I looked at the sources of PdfBox and Ghostscript to see how they handle this > case and: > * Ghostscript searches through the entire file (see > [https://github.com/ArtifexSoftware/ghostpdl/blob/master/pdf/ghostpdf.c] > lines 1323-1339) > * PdfBox reads the file line by line, and stops looking for the header when > it encounters a line that starts with a digit (see > [https://github.com/apache/pdfbox/blob/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java] > lines 1561-) > From the doc in tika-mimetypes.xml for the application/pdf MIME type, I > understand that increasing the maximum offset can trigger false positives. I > increased it to 768, and the unit tests pass, but I didn't find any PDF that > tests this particular case, so either it doesn't exist or there are > integration tests that aren't part of this repo ? > How can I go about testing for regressions ? I can provide a pull request for > this change, but where do I put the test PDF and a unit test? -- This message was sent by Atlassian Jira (v8.20.10#820010)