dschmidt opened a new pull request, #3553:
URL: https://github.com/apache/tika/pull/3553

   [TIKA-5041](https://issues.apache.org/jira/browse/TIKA-5041)
   
   #3530 gave `.cbz` its cover. This does the same for comic book archives in 
RAR, 7z and tar: `application/vnd.comicbook-rar` (`.cbr`, IANA-registered, 
alias `application/x-cbr`), `application/x-cb7` (`.cb7`) and 
`application/x-cbt` (`.cbt`), new sub-types of their containers. `RarParser`, 
`SevenZParser` and `PackageParser` keep the comic type and mark the first page 
in name order as the `THUMBNAIL`; the choice is the one `ZipPreview` makes for 
`.cbz`, now shared in `ComicBook`. For tar, the names come from `TarFile` 
first, as a streamed tar gives them only one by one.
   
   Detection needed a local workaround. A name or declared type replaces the 
magic type only when it is a sub-type of it, and the magic of a RAR is 
`application/x-rar-compressed; version=4` or `version=5`, that of a GNU tar 
`application/x-gtar`; neither has the comic types below it, so a `.cbr` stayed 
a RAR whatever its name or declared type said. `ComicBookDetector` returns the 
comic type when the name ends in `.cbr`, `.cb7` or `.cbt`, or the declared type 
is a comic type, and the content starts with the matching container's magic.
   
   ## To be decided: fix the hint rule instead?
   
   The general fix would be in `MimeTypes.applyHint`: let a hint win when it 
specializes the base of a parameterized magic type (`x-rar-compressed` for 
`x-rar-compressed; version=5`), and treat GNU tar as a variant of tar. That 
would make the detector unnecessary and help any other format sitting on a 
versioned container, but it changes detection for every type with such 
variants, PDF versions included. I went with the contained detector for now; 
happy to switch if you prefer the general one.
   
   Checked with two real `.cbr` (RAR4 and RAR5), two real `.cb7` and a POSIX 
and a GNU `.cbt` built with tar, each for detection (with the name, with only 
the declared type, with neither), parsing and `/unpack/preset/thumbnail`: all 
give the comic type from a name or a declared type and their first page as the 
thumbnail; without either they stay plain archives, as `.cbz` does. Tests cover 
the detector, a RAR5, a 7z and a POSIX and GNU tar with pages stored out of 
order.
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to