aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBart Ribbers <bribbers@disroot.org>2021-05-14 15:10:43 +0200
committerBart Ribbers <bribbers@disroot.org>2021-05-14 13:50:13 +0000
commit41207e67103ff08bf99f014cc516cd8535b2ebc5 (patch)
tree08e01d128d7f2842778da9ea3e97e031b31913d1
parent8092a9ac923a78350c34f39bf3ed07c4c2c33155 (diff)
downloadaports-41207e67103ff08bf99f014cc516cd8535b2ebc5.tar.gz
aports-41207e67103ff08bf99f014cc516cd8535b2ebc5.tar.bz2
aports-41207e67103ff08bf99f014cc516cd8535b2ebc5.tar.xz
community/kio: backport patches as requested upstream
Fixes a memory leak
-rw-r--r--community/kio/0001-resolve-symlinks-for-local-file.patch115
-rw-r--r--community/kio/0002-fix-mimetypefinderjob-to-not-always-use-kio-get.patch156
-rw-r--r--community/kio/APKBUILD13
3 files changed, 281 insertions, 3 deletions
diff --git a/community/kio/0001-resolve-symlinks-for-local-file.patch b/community/kio/0001-resolve-symlinks-for-local-file.patch
new file mode 100644
index 0000000000..cb11437f8b
--- /dev/null
+++ b/community/kio/0001-resolve-symlinks-for-local-file.patch
@@ -0,0 +1,115 @@
+From 52cee21e3912bf7b20671762f3d7c991b802eb75 Mon Sep 17 00:00:00 2001
+From: Jonathan Marten <jjm@keelhaul.me.uk>
+Date: Fri, 7 May 2021 21:13:26 +0100
+Subject: [PATCH 1/3] MimeTypeFinderJob: Resolve symlinks for a local file
+
+Since we are most likely to be interested in the MIME type of the
+target (for opening it).
+
+BUG:436708
+---
+ src/core/mimetypefinderjob.cpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/core/mimetypefinderjob.cpp b/src/core/mimetypefinderjob.cpp
+index f5e50cdc4..48fc8c289 100644
+--- a/src/core/mimetypefinderjob.cpp
++++ b/src/core/mimetypefinderjob.cpp
+@@ -122,7 +122,7 @@ void KIO::MimeTypeFinderJobPrivate::statFile()
+ {
+ Q_ASSERT(m_mimeTypeName.isEmpty());
+
+- KIO::StatJob *job = KIO::statDetails(m_url, KIO::StatJob::SourceSide, KIO::StatBasic, KIO::HideProgressInfo);
++ KIO::StatJob *job = KIO::statDetails(m_url, KIO::StatJob::SourceSide, KIO::StatBasic | KIO::StatResolveSymlink, KIO::HideProgressInfo);
+ if (!m_authPrompts) {
+ job->addMetaData(QStringLiteral("no-auth-prompt"), QStringLiteral("true"));
+ }
+--
+GitLab
+
+
+From 11cb5e5126367c470fd9c88bca90e9d94b43a627 Mon Sep 17 00:00:00 2001
+From: Jonathan Marten <jjm@keelhaul.me.uk>
+Date: Sat, 8 May 2021 13:56:52 +0100
+Subject: [PATCH 2/3] MimeTypeFinderJob: Add autotest for access through
+ symlink
+
+Also tests MIME type resolution for a directory (since the job only
+fails for a directory accessed through a symlink).
+---
+ autotests/mimetypefinderjobtest.cpp | 18 +++++++++++++++++-
+ 1 file changed, 17 insertions(+), 1 deletion(-)
+
+diff --git a/autotests/mimetypefinderjobtest.cpp b/autotests/mimetypefinderjobtest.cpp
+index 72296b9b8..df00e9d8e 100644
+--- a/autotests/mimetypefinderjobtest.cpp
++++ b/autotests/mimetypefinderjobtest.cpp
+@@ -48,6 +48,7 @@ void MimeTypeFinderJobTest::determineMimeType_data()
+ QTest::newRow("text_file_no_extension") << "text/plain" << "srcfile";
+ QTest::newRow("desktop_file") << "application/x-desktop" << "foo.desktop";
+ QTest::newRow("script") << "application/x-shellscript" << "srcfile.sh";
++ QTest::newRow("directory") << "inode/directory" << "srcdir";
+ /* clang-format on */
+ }
+
+@@ -60,7 +61,12 @@ void MimeTypeFinderJobTest::determineMimeType()
+ QTemporaryDir tempDir;
+ const QString srcDir = tempDir.path();
+ const QString srcFile = srcDir + QLatin1Char('/') + fileName;
+- createSrcFile(srcFile);
++ if (mimeType == "inode/directory") {
++ QVERIFY(QDir(srcDir).mkdir(fileName));
++ } else {
++ createSrcFile(srcFile);
++ }
++
+ QVERIFY(QFile::exists(srcFile));
+ const QUrl url = QUrl::fromLocalFile(srcFile);
+
+@@ -68,6 +74,16 @@ void MimeTypeFinderJobTest::determineMimeType()
+ KIO::MimeTypeFinderJob *job = new KIO::MimeTypeFinderJob(url, this);
+ QVERIFY2(job->exec(), qPrintable(job->errorString()));
+ QCOMPARE(job->mimeType(), mimeType);
++
++ // Check that the result is the same when accessing the source
++ // file through a symbolic link (bug #436708)
++ const QString srcLink = srcDir + QLatin1Char('/') + QLatin1String("link_") + fileName;
++ QVERIFY(QFile::link(srcFile, srcLink));
++ const QUrl linkUrl = QUrl::fromLocalFile(srcLink);
++
++ job = new KIO::MimeTypeFinderJob(linkUrl, this);
++ QVERIFY2(job->exec(), qPrintable(job->errorString()));
++ QCOMPARE(job->mimeType(), mimeType);
+ }
+
+ void MimeTypeFinderJobTest::invalidUrl()
+--
+GitLab
+
+
+From c49110dab55d9ae2212e0235bdb11fac6d2ae0e5 Mon Sep 17 00:00:00 2001
+From: Jonathan Marten <jjm@keelhaul.me.uk>
+Date: Sat, 8 May 2021 14:47:04 +0100
+Subject: [PATCH 3/3] MimeTypeFinderJob test: Combine a QLatin1Char and a
+ QLatin1String
+
+---
+ autotests/mimetypefinderjobtest.cpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/autotests/mimetypefinderjobtest.cpp b/autotests/mimetypefinderjobtest.cpp
+index df00e9d8e..f494ff3b6 100644
+--- a/autotests/mimetypefinderjobtest.cpp
++++ b/autotests/mimetypefinderjobtest.cpp
+@@ -77,7 +77,7 @@ void MimeTypeFinderJobTest::determineMimeType()
+
+ // Check that the result is the same when accessing the source
+ // file through a symbolic link (bug #436708)
+- const QString srcLink = srcDir + QLatin1Char('/') + QLatin1String("link_") + fileName;
++ const QString srcLink = srcDir + QLatin1String("/link_") + fileName;
+ QVERIFY(QFile::link(srcFile, srcLink));
+ const QUrl linkUrl = QUrl::fromLocalFile(srcLink);
+
+--
+GitLab
+
diff --git a/community/kio/0002-fix-mimetypefinderjob-to-not-always-use-kio-get.patch b/community/kio/0002-fix-mimetypefinderjob-to-not-always-use-kio-get.patch
new file mode 100644
index 0000000000..be128f3e0e
--- /dev/null
+++ b/community/kio/0002-fix-mimetypefinderjob-to-not-always-use-kio-get.patch
@@ -0,0 +1,156 @@
+From c748d6987252fafc296cde9351b289ef734cf861 Mon Sep 17 00:00:00 2001
+From: Ahmad Samir <a.samirh78@gmail.com>
+Date: Thu, 13 May 2021 23:03:57 +0200
+Subject: [PATCH 1/3] kio_file: pass the absolute path to
+ QMimeDatabase::mimeTypeForFile()
+
+Otherwise detecting the mime type based on the file content may fail and
+return application/octet-stream.
+
+And pass the whole url to createUDSEntry(), less QFile::decodeName/encodeName()
+in the middle is better and less error prone.
+
+Note that without this change a MimeTypeFinderJob could end up failing to
+find the mime type of a local file based on the file contents.
+---
+ src/ioslaves/file/file_unix.cpp | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/src/ioslaves/file/file_unix.cpp b/src/ioslaves/file/file_unix.cpp
+index 99d46c8f1..940e3cbc4 100644
+--- a/src/ioslaves/file/file_unix.cpp
++++ b/src/ioslaves/file/file_unix.cpp
+@@ -364,7 +364,7 @@ inline static time_t stat_mtime(QT_STATBUF &buf)
+ }
+ #endif
+
+-static bool createUDSEntry(const QString &filename, const QByteArray &path, UDSEntry &entry, KIO::StatDetails details)
++static bool createUDSEntry(const QString &filename, const QByteArray &path, UDSEntry &entry, KIO::StatDetails details, const QUrl &url)
+ {
+ assert(entry.count() == 0); // by contract :-)
+ int entries = 0;
+@@ -539,7 +539,7 @@ static bool createUDSEntry(const QString &filename, const QByteArray &path, UDSE
+
+ if (details & KIO::StatMimeType) {
+ QMimeDatabase db;
+- entry.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, db.mimeTypeForFile(filename).name());
++ entry.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, db.mimeTypeForFile(url.toLocalFile()).name());
+ }
+
+ return true;
+@@ -1186,7 +1186,7 @@ void FileProtocol::listDir(const QUrl &url)
+ listEntry(entry);
+
+ } else {
+- if (createUDSEntry(filename, QByteArray(ep->d_name), entry, details)) {
++ if (createUDSEntry(filename, QByteArray(ep->d_name), entry, details, url)) {
+ #if HAVE_SYS_XATTR_H
+ if (isNtfsHidden(filename)) {
+ bool ntfsHidden = true;
+@@ -1476,7 +1476,7 @@ void FileProtocol::stat(const QUrl &url)
+ const KIO::StatDetails details = getStatDetails();
+
+ UDSEntry entry;
+- if (!createUDSEntry(url.fileName(), _path, entry, details)) {
++ if (!createUDSEntry(url.fileName(), _path, entry, details, url)) {
+ error(KIO::ERR_DOES_NOT_EXIST, path);
+ return;
+ }
+--
+GitLab
+
+
+From c19876052ecec18a87a82f5950e8909e22e895ba Mon Sep 17 00:00:00 2001
+From: Ahmad Samir <a.samirh78@gmail.com>
+Date: Thu, 13 May 2021 17:02:52 +0200
+Subject: [PATCH 2/3] MimeTypeFinderJob: the StatJob details should include the
+ mimetype
+
+Apparently we forgot to specify that we want the UDS_MIME_TYPE field in
+the statFile() method (both when it lived in OpenUrlJob and when it was moved
+to MimeTypeFinderJob). And now there is a dedicated StatJob flag, StatMimeType,
+that we can use.
+
+Not passing KIO::StatMimeType when creating the StatJob meant the code always
+used a get job to determine the mime type, which mean that e.g. opening an
+ISO file from Dolphin, which supposedly just needs to launch Ark, had the
+whole file read into memory, which means that opening a couple of ISO's and
+you're out of memory...
+
+Thanks to sitter for doing a big chunk of the investigative work in the bug
+report.
+
+CCBUG: 398908
+---
+ src/core/mimetypefinderjob.cpp | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/src/core/mimetypefinderjob.cpp b/src/core/mimetypefinderjob.cpp
+index 48fc8c289..baca58695 100644
+--- a/src/core/mimetypefinderjob.cpp
++++ b/src/core/mimetypefinderjob.cpp
+@@ -122,7 +122,9 @@ void KIO::MimeTypeFinderJobPrivate::statFile()
+ {
+ Q_ASSERT(m_mimeTypeName.isEmpty());
+
+- KIO::StatJob *job = KIO::statDetails(m_url, KIO::StatJob::SourceSide, KIO::StatBasic | KIO::StatResolveSymlink, KIO::HideProgressInfo);
++ static constexpr auto statFlags = KIO::StatBasic | KIO::StatResolveSymlink | KIO::StatMimeType;
++
++ KIO::StatJob *job = KIO::statDetails(m_url, KIO::StatJob::SourceSide, statFlags, KIO::HideProgressInfo);
+ if (!m_authPrompts) {
+ job->addMetaData(QStringLiteral("no-auth-prompt"), QStringLiteral("true"));
+ }
+@@ -147,6 +149,8 @@ void KIO::MimeTypeFinderJobPrivate::statFile()
+
+ const KIO::UDSEntry entry = job->statResult();
+
++ qCDebug(KIO_CORE) << "UDSEntry from StatJob in MimeTypeFinderJob" << entry;
++
+ const QString localPath = entry.stringValue(KIO::UDSEntry::UDS_LOCAL_PATH);
+ if (!localPath.isEmpty()) {
+ m_url = QUrl::fromLocalFile(localPath);
+--
+GitLab
+
+
+From 6c5014598d524ca419c8886baa48188bba39dacb Mon Sep 17 00:00:00 2001
+From: Ahmad Samir <a.samirh78@gmail.com>
+Date: Thu, 13 May 2021 18:40:49 +0200
+Subject: [PATCH 3/3] StatDetail enum: improve API docs
+
+NO_CHANGELOG
+---
+ src/core/global.h | 11 +++++++----
+ 1 file changed, 7 insertions(+), 4 deletions(-)
+
+diff --git a/src/core/global.h b/src/core/global.h
+index 44e0fb06a..449ccf539 100644
+--- a/src/core/global.h
++++ b/src/core/global.h
+@@ -335,16 +335,19 @@ enum StatDetail {
+ StatTime = 0x4,
+ /// Resolve symlinks
+ StatResolveSymlink = 0x8,
+- /// acl Data
++ /// ACL data
+ StatAcl = 0x10,
+ /// dev, inode
+ StatInode = 0x20,
+- /// recursive size @since 5.70
++ /// Recursive size
++ /// @since 5.70
+ StatRecursiveSize = 0x40,
+- /// mime type @since 5.82
++ /// Mime Type
++ /// @since 5.82
+ StatMimeType = 0x80,
+
+- /// Default value includes fields provided by other entries
++ /// Default StatDetail flag when creating a @c StatJob.
++ /// Equivalent to setting <tt>StatBasic | StatUser | StatTime | StatAcl | StatResolveSymlink</tt>
+ StatDefaultDetails = StatBasic | StatUser | StatTime | StatAcl | StatResolveSymlink,
+ };
+ /**
+--
+GitLab
+
diff --git a/community/kio/APKBUILD b/community/kio/APKBUILD
index 08bcb8278e..9d46c76629 100644
--- a/community/kio/APKBUILD
+++ b/community/kio/APKBUILD
@@ -2,9 +2,11 @@
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=kio
pkgver=5.82.0
-pkgrel=0
+pkgrel=1
pkgdesc="Resource and network access abstraction"
-arch="all !armhf !mips64 !s390x" # armhf blocked by extra-cmake-modules and mips64, s390x blocked by polkit
+ # armhf blocked by extra-cmake-modules
+ # mips64 and s390x blocked by polkit
+arch="all !armhf !mips64 !s390x"
url="https://community.kde.org/Frameworks"
license="LGPL-2.1-only AND LGPL-2.1-or-later AND (LGPL-2.1-only OR LGPL-3.0-only)"
depends_dev="
@@ -37,7 +39,10 @@ makedepends="$depends_dev
qt5-qttools-dev
"
checkdepends="xvfb-run"
-source="https://download.kde.org/stable/frameworks/${pkgver%.*}/kio-$pkgver.tar.xz"
+source="https://download.kde.org/stable/frameworks/${pkgver%.*}/kio-$pkgver.tar.xz
+ 0001-resolve-symlinks-for-local-file.patch
+ 0002-fix-mimetypefinderjob-to-not-always-use-kio-get.patch
+ "
subpackages="$pkgname-dev $pkgname-doc $pkgname-lang"
options="!check" # Fails due to requiring physical devices not normally available and test 14 hangs
@@ -60,4 +65,6 @@ package() {
}
sha512sums="
a14f42a8c96fb8b1f435d4120805628f877132b588c2c1f983af6409603baffbcdad99f1c296fef99dd78fb7edbf526fd95f85970ccbf91887619eb5728cb3dc kio-5.82.0.tar.xz
+0ced4c7154d0cbbe6f4680bbec6461a273ad2642d1823ce5f9ed4937508aded792274699c96959bbc25b20175e3089955d196d9ffdc1bff5ded6d239768baade 0001-resolve-symlinks-for-local-file.patch
+5c71c6fdd3f3d10345155a57f65d659787154bb46e422ce9fc535ccb7df8d855658b76ddd0f4bf139e238f6e1a4aaf35983dfd7538e02ed7e17c7886b63393cb 0002-fix-mimetypefinderjob-to-not-always-use-kio-get.patch
"