Commit 5c86cccc authored by Jan Felix Langenbach's avatar Jan Felix Langenbach Committed by Elvis Angelaccio
Browse files

Fix handling of MIME subtypes of compressed tar archives.

Change determineMimeType in mimetypes.cpp to use
QMimeType.inherits() instead of QMimeType.operator== when
checking if the MIME type determined from the file extension
is that of a compressed tar archive.
This fixes the handling of files that use MIME subtypes of
application/x-compressed-tar etc. This is needed to be able to
extract ALPM packages used by Arch Linux.
See bug 416092.
parent c42a4545
......@@ -91,23 +91,23 @@ QMimeType determineMimeType(const QString& filename)
// Compressed tar-archives are detected as single compressed files when
// detecting by content. The following code fixes detection of tar.gz, tar.bz2, tar.xz,
// tar.lzo, tar.lz, tar.lrz and tar.zst.
if ((mimeFromExtension == db.mimeTypeForName(QStringLiteral("application/x-compressed-tar")) &&
if ((mimeFromExtension.inherits(QStringLiteral("application/x-compressed-tar")) &&
mimeFromContent == db.mimeTypeForName(QStringLiteral("application/gzip"))) ||
(mimeFromExtension == db.mimeTypeForName(QStringLiteral("application/x-bzip-compressed-tar")) &&
(mimeFromExtension.inherits(QStringLiteral("application/x-bzip-compressed-tar")) &&
mimeFromContent == db.mimeTypeForName(QStringLiteral("application/x-bzip"))) ||
(mimeFromExtension == db.mimeTypeForName(QStringLiteral("application/x-xz-compressed-tar")) &&
(mimeFromExtension.inherits(QStringLiteral("application/x-xz-compressed-tar")) &&
mimeFromContent == db.mimeTypeForName(QStringLiteral("application/x-xz"))) ||
(mimeFromExtension == db.mimeTypeForName(QStringLiteral("application/x-tarz")) &&
(mimeFromExtension.inherits(QStringLiteral("application/x-tarz")) &&
mimeFromContent == db.mimeTypeForName(QStringLiteral("application/x-compress"))) ||
(mimeFromExtension == db.mimeTypeForName(QStringLiteral("application/x-tzo")) &&
(mimeFromExtension.inherits(QStringLiteral("application/x-tzo")) &&
mimeFromContent == db.mimeTypeForName(QStringLiteral("application/x-lzop"))) ||
(mimeFromExtension == db.mimeTypeForName(QStringLiteral("application/x-lzip-compressed-tar")) &&
(mimeFromExtension.inherits(QStringLiteral("application/x-lzip-compressed-tar")) &&
mimeFromContent == db.mimeTypeForName(QStringLiteral("application/x-lzip"))) ||
(mimeFromExtension == db.mimeTypeForName(QStringLiteral("application/x-lrzip-compressed-tar")) &&
(mimeFromExtension.inherits(QStringLiteral("application/x-lrzip-compressed-tar")) &&
mimeFromContent == db.mimeTypeForName(QStringLiteral("application/x-lrzip"))) ||
(mimeFromExtension == db.mimeTypeForName(QStringLiteral("application/x-lz4-compressed-tar")) &&
(mimeFromExtension.inherits(QStringLiteral("application/x-lz4-compressed-tar")) &&
mimeFromContent == db.mimeTypeForName(QStringLiteral("application/x-lz4"))) ||
(mimeFromExtension == db.mimeTypeForName(QStringLiteral("application/x-zstd-compressed-tar")) &&
(mimeFromExtension.inherits(QStringLiteral("application/x-zstd-compressed-tar")) &&
mimeFromContent == db.mimeTypeForName(QStringLiteral("application/zstd")))) {
return mimeFromExtension;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment