summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRagnar Thomsen <rthomsen6@gmail.com>2016-10-04 20:21:03 (GMT)
committerRagnar Thomsen <rthomsen6@gmail.com>2016-10-04 20:21:03 (GMT)
commitc311157525337d6a12bbc3da445e0c22e77f58d9 (patch)
tree43c56a3688b0db91f54d2b0684e3856531a312ec
parent7bba06c67085f247ef16b7570072b2e48157b541 (diff)
Enable support for application/x-archive
Read-only support for application/x-archive (AR archives) which is mostly used for static libraries (*.a) was enabled in libarchiveplugin. Due to static libraries containing the two entries "/" and "//", code was added to skip these entries to avoid the "absolute path" error. This enables extraction of this archive type. FEATURE: Differential Revision: D2904
-rw-r--r--plugins/libarchive/CMakeLists.txt5
-rw-r--r--plugins/libarchive/libarchiveplugin.cpp7
2 files changed, 10 insertions, 2 deletions
diff --git a/plugins/libarchive/CMakeLists.txt b/plugins/libarchive/CMakeLists.txt
index 9585c43..0d81973 100644
--- a/plugins/libarchive/CMakeLists.txt
+++ b/plugins/libarchive/CMakeLists.txt
@@ -4,7 +4,7 @@ include_directories(${LibArchive_INCLUDE_DIRS})
set(SUPPORTED_LIBARCHIVE_READWRITE_MIMETYPES "application/x-tar;application/x-compressed-tar;application/x-bzip-compressed-tar;application/x-tarz;application/x-xz-compressed-tar;")
set(SUPPORTED_LIBARCHIVE_READWRITE_MIMETYPES "${SUPPORTED_LIBARCHIVE_READWRITE_MIMETYPES}application/x-lzma-compressed-tar;application/x-lzip-compressed-tar;application/x-tzo;application/x-lrzip-compressed-tar;")
set(SUPPORTED_LIBARCHIVE_READONLY_MIMETYPES "application/vnd.debian.binary-package;application/x-deb;application/x-cd-image;application/x-bcpio;application/x-cpio;application/x-cpio-compressed;application/x-sv4cpio;application/x-sv4crc;")
-set(SUPPORTED_LIBARCHIVE_READONLY_MIMETYPES "${SUPPORTED_LIBARCHIVE_READONLY_MIMETYPES}application/x-rpm;application/x-source-rpm;application/vnd.ms-cab-compressed;application/x-xar;application/x-iso9660-appimage;")
+set(SUPPORTED_LIBARCHIVE_READONLY_MIMETYPES "${SUPPORTED_LIBARCHIVE_READONLY_MIMETYPES}application/x-rpm;application/x-source-rpm;application/vnd.ms-cab-compressed;application/x-xar;application/x-iso9660-appimage;application/x-archive;")
if(LibArchive_VERSION VERSION_EQUAL "3.2.0" OR
LibArchive_VERSION VERSION_GREATER "3.2.0")
@@ -37,7 +37,8 @@ set(SUPPORTED_READONLY_MIMETYPES
\"application/vnd.debian.binary-package\",
\"application/vnd.ms-cab-compressed\",
\"application/x-xar\",
- \"application/x-iso9660-appimage")
+ \"application/x-iso9660-appimage\",
+ \"application/x-archive")
# NOTE: the first double-quotes of the first mime and the last
# double-quotes of the last mime must NOT be escaped.
diff --git a/plugins/libarchive/libarchiveplugin.cpp b/plugins/libarchive/libarchiveplugin.cpp
index da59a7b..9c389a9 100644
--- a/plugins/libarchive/libarchiveplugin.cpp
+++ b/plugins/libarchive/libarchiveplugin.cpp
@@ -224,6 +224,13 @@ bool LibarchivePlugin::extractFiles(const QList<Archive::Entry*> &files, const Q
entryName.remove(0, 2);
}
+ // Static libraries (*.a) contain the two entries "/" and "//".
+ // We just skip these to allow extracting this archive type.
+ if (entryName == QLatin1String("/") || entryName == QLatin1String("//")) {
+ archive_read_data_skip(m_archiveReader.data());
+ continue;
+ }
+
// For now we just can't handle absolute filenames in a tar archive.
// TODO: find out what to do here!!
if (entryName.startsWith(QLatin1Char( '/' ))) {