Uploaded image for project: 'Tika'
  1. Tika
  2. TIKA-3596

Detect truncated/bad encoded XML files as application/xml instead of text/plain

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 1.27, 2.1.0
    • 2.2.0, 1.28
    • detector
    • None

    Description

      There is a logic in MimeTypes class to return text/plain for corrupted xml files not detected as text/html here: https://github.com/apache/tika/blob/324f2f2ccff21c608969e2e79da88e71379a58dc/tika-core/src/main/java/org/apache/tika/mime/MimeTypes.java#L281

      I think this should be changed to return application/xml, even if the file is corrupted, like is done for all other mimetypes, being more consistent across file formats. Even if a jpg or doc file is corrupted, image/jpg or application/msword is returned.

      I have about ~2k from ~90k xml files in an internal corpus that trigger this.

      If other fellow devs agree, I can submit a patch and unit test.

      Attachments

        1. test.xyz
          0.6 kB
          Luís Filipe Nassif

        Activity

          People

            lfcnassif Luís Filipe Nassif
            lfcnassif Luís Filipe Nassif
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: