Review Request 124442: Improve detection of mimetype

Ragnar Thomsen rthomsen6 at gmail.com
Mon Aug 3 18:44:54 UTC 2015



> On Aug. 1, 2015, 10:49 p.m., Elvis Angelaccio wrote:
> > kerfuffle/archive_kerfuffle.cpp, lines 64-74
> > <https://git.reviewboard.kde.org/r/124442/diff/4/?file=388410#file388410line64>
> >
> >     Why the detection is broken for tar archives? Upstream qt bug? This workaround should work in most of the cases, but what if a gzip archive is renamed to .tar.gz? In this case the `mimeFromExtension` would be used and Ark would file to open that archive.
> 
> Elvis Angelaccio wrote:
>     * would *fail* to open ...

I don't think it is a bug in Qt. At least `file --mime-type` also presents compressed tars as application/gzip, application/x-bzip or application/x-xz. I guess there's just no way of knowing if a gzipped file contains a tar archive (apart from the extension) without decompressing it, which would be unfeasible for large files.

You're right that if a gzipped file is renamed to a tar.gz, Ark will attempt to open it using libarchive plugin and fail. But that's no different from what Ark currently does. At least with this patch all other forms of wrongly-named archives should open. I can't see how we can fix this without extracting the file and checking...


- Ragnar


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/124442/#review83309
-----------------------------------------------------------


On July 29, 2015, 2:05 p.m., Ragnar Thomsen wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/124442/
> -----------------------------------------------------------
> 
> (Updated July 29, 2015, 2:05 p.m.)
> 
> 
> Review request for KDE Utils, Elvis Angelaccio and Raphael Kubo da Costa.
> 
> 
> Bugs: 101170 and 265971
>     http://bugs.kde.org/show_bug.cgi?id=101170
>     http://bugs.kde.org/show_bug.cgi?id=265971
> 
> 
> Repository: ark
> 
> 
> Description
> -------
> 
> This patch improves the mimetype detection when opening archives. Previously, the filename extension had higher priority than file content when determining mimetype. When opening an archive that had a wrong extension (as in bug 265971), this resulted in Ark failing to open it.
> 
> With this patch the mimetype is determined from file content. Additionally, a warning is shown in console output when mimetype from extension and content do not match.
> 
> 
> Diffs
> -----
> 
>   kerfuffle/archive_kerfuffle.cpp 7b9990d 
> 
> Diff: https://git.reviewboard.kde.org/r/124442/diff/
> 
> 
> Testing
> -------
> 
> Opening archives with wrong filename extensions now works as expected.
> 
> 
> Thanks,
> 
> Ragnar Thomsen
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-utils-devel/attachments/20150803/cbef8dfe/attachment.html>


More information about the Kde-utils-devel mailing list