diff --git a/debian/changelog b/debian/changelog index 6a03cd3..19d970d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +kio (5.82.0-3) experimental; urgency=medium + + [ Norbert Preining ] + * Cherry-pick another fix according to upstream. + + -- Norbert Preining Sun, 16 May 2021 20:54:16 +0900 + kio (5.82.0-2) experimental; urgency=medium [ Norbert Preining ] diff --git a/debian/patches/0001-MimeTypeFinderJob-Resolve-symlinks-for-a-local-file.patch b/debian/patches/0001-MimeTypeFinderJob-Resolve-symlinks-for-a-local-file.patch new file mode 100644 index 0000000..a100b0e --- /dev/null +++ b/debian/patches/0001-MimeTypeFinderJob-Resolve-symlinks-for-a-local-file.patch @@ -0,0 +1,69 @@ +From 21d516bd69ba989374426a3466231f4ed7c5f796 Mon Sep 17 00:00:00 2001 +From: Jonathan Marten +Date: Sat, 8 May 2021 15:20:39 +0000 +Subject: [PATCH 1/4] MimeTypeFinderJob: Resolve symlinks for a local file + +--- + autotests/mimetypefinderjobtest.cpp | 18 +++++++++++++++++- + src/core/mimetypefinderjob.cpp | 2 +- + 2 files changed, 18 insertions(+), 2 deletions(-) + +diff --git a/autotests/mimetypefinderjobtest.cpp b/autotests/mimetypefinderjobtest.cpp +index 72296b9b..f494ff3b 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 + 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() +diff --git a/src/core/mimetypefinderjob.cpp b/src/core/mimetypefinderjob.cpp +index f5e50cdc..48fc8c28 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")); + } +-- +2.31.1 + diff --git a/debian/patches/0002-kio_file-pass-the-absolute-path-to-QMimeDatabase-mim.patch b/debian/patches/0002-kio_file-pass-the-absolute-path-to-QMimeDatabase-mim.patch new file mode 100644 index 0000000..36ef900 --- /dev/null +++ b/debian/patches/0002-kio_file-pass-the-absolute-path-to-QMimeDatabase-mim.patch @@ -0,0 +1,61 @@ +From 665c0f5cdd302f74d8bdb59fba8fc2e2313c6bf6 Mon Sep 17 00:00:00 2001 +From: Ahmad Samir +Date: Thu, 13 May 2021 23:03:57 +0200 +Subject: [PATCH 2/4] 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 99d46c8f..940e3cbc 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; + } +-- +2.31.1 + diff --git a/debian/patches/0003-MimeTypeFinderJob-the-StatJob-details-should-include.patch b/debian/patches/0003-MimeTypeFinderJob-the-StatJob-details-should-include.patch new file mode 100644 index 0000000..abcf79d --- /dev/null +++ b/debian/patches/0003-MimeTypeFinderJob-the-StatJob-details-should-include.patch @@ -0,0 +1,52 @@ +From 7732251924dbd907351f847ae731058af713bbc8 Mon Sep 17 00:00:00 2001 +From: Ahmad Samir +Date: Thu, 13 May 2021 17:02:52 +0200 +Subject: [PATCH 3/4] 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 48fc8c28..baca5869 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); +-- +2.31.1 + diff --git a/debian/patches/0004-kio_file-fix-how-createUDSEntry-is-called.patch b/debian/patches/0004-kio_file-fix-how-createUDSEntry-is-called.patch new file mode 100644 index 0000000..09c26c8 --- /dev/null +++ b/debian/patches/0004-kio_file-fix-how-createUDSEntry-is-called.patch @@ -0,0 +1,62 @@ +From aefc86886a9e76b8a0d44e0e16d2ce502d5c9f7e Mon Sep 17 00:00:00 2001 +From: Ahmad Samir +Date: Fri, 14 May 2021 21:19:31 +0200 +Subject: [PATCH 4/4] kio_file: fix how createUDSEntry() is called + +When calling createUDSEntry() from listDir(), we need to concatenate the full +path to the item. + +This is an addendum to commit c748d6987252f. +--- + src/ioslaves/file/file_unix.cpp | 14 ++++++++++---- + 1 file changed, 10 insertions(+), 4 deletions(-) + +diff --git a/src/ioslaves/file/file_unix.cpp b/src/ioslaves/file/file_unix.cpp +index 940e3cbc..3573c200 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, const QUrl &url) ++static bool createUDSEntry(const QString &filename, const QByteArray &path, UDSEntry &entry, KIO::StatDetails details, const QString &fullPath) + { + 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(url.toLocalFile()).name()); ++ entry.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, db.mimeTypeForFile(fullPath).name()); + } + + return true; +@@ -1186,7 +1186,13 @@ void FileProtocol::listDir(const QUrl &url) + listEntry(entry); + + } else { +- if (createUDSEntry(filename, QByteArray(ep->d_name), entry, details, url)) { ++ QString fullPath(path); ++ if (!fullPath.endsWith(QLatin1Char('/'))) { ++ fullPath += QLatin1Char('/'); ++ } ++ fullPath += filename; ++ ++ if (createUDSEntry(filename, QByteArray(ep->d_name), entry, details, fullPath)) { + #if HAVE_SYS_XATTR_H + if (isNtfsHidden(filename)) { + bool ntfsHidden = true; +@@ -1476,7 +1482,7 @@ void FileProtocol::stat(const QUrl &url) + const KIO::StatDetails details = getStatDetails(); + + UDSEntry entry; +- if (!createUDSEntry(url.fileName(), _path, entry, details, url)) { ++ if (!createUDSEntry(url.fileName(), _path, entry, details, path)) { + error(KIO::ERR_DOES_NOT_EXIST, path); + return; + } +-- +2.31.1 + diff --git a/debian/patches/kio-upstream-patches-from-freebsd b/debian/patches/kio-upstream-patches-from-freebsd deleted file mode 100644 index bb74fa0..0000000 --- a/debian/patches/kio-upstream-patches-from-freebsd +++ /dev/null @@ -1,142 +0,0 @@ -From aa6092a1dbfad606ad6430c71eec6add0bbdb4cf Mon Sep 17 00:00:00 2001 -From: Adriaan de Groot -Date: Fri, 14 May 2021 18:15:52 +0200 -Subject: devel/kf5-kio: backport regression-fixes from upstream - -Upstream reports that the following three commits should be -backported for improved performance and accuracy for -mimetype detection in KIO-using applications: - -(In https://invent.kde.org/frameworks/kio/commit/) - c748d6987252fafc296cde9351b289ef734cf861 - e79da836c34fce66231e396c7215314d0eba51b4 - c19876052ecec18a87a82f5950e8909e22e895ba ---- - .../patch-autotests_mimetypefinderjobtest.cpp | 39 ++++++++++++++++++++++ - .../files/patch-src_core_mimetypefinderjob.cpp | 22 ++++++++++++ - .../files/patch-src_ioslaves_file_file__unix.cpp | 38 +++++++++++++++++++++ - 4 files changed, 100 insertions(+) - create mode 100644 devel/kf5-kio/files/patch-autotests_mimetypefinderjobtest.cpp - create mode 100644 devel/kf5-kio/files/patch-src_core_mimetypefinderjob.cpp - create mode 100644 devel/kf5-kio/files/patch-src_ioslaves_file_file__unix.cpp - -diff --git a/devel/kf5-kio/files/patch-autotests_mimetypefinderjobtest.cpp b/devel/kf5-kio/files/patch-autotests_mimetypefinderjobtest.cpp -new file mode 100644 -index 000000000000..c0dd474fc18c ---- /dev/null -+++ b/devel/kf5-kio/files/patch-autotests_mimetypefinderjobtest.cpp -@@ -0,0 +1,39 @@ -+--- autotests/mimetypefinderjobtest.cpp.orig 2021-05-06 17:50:59 UTC -++++ 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,12 +61,27 @@ 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); -+ -+ // When running a MimeTypeFinderJob -+ 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 + 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); -+ } -diff --git a/devel/kf5-kio/files/patch-src_core_mimetypefinderjob.cpp b/devel/kf5-kio/files/patch-src_core_mimetypefinderjob.cpp -new file mode 100644 -index 000000000000..42c0b4929b01 ---- /dev/null -+++ b/devel/kf5-kio/files/patch-src_core_mimetypefinderjob.cpp -@@ -0,0 +1,22 @@ -+--- src/core/mimetypefinderjob.cpp.orig 2021-05-14 15:38:26 UTC -++++ 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::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")); -+ } -+@@ -146,6 +148,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()) { -diff --git a/devel/kf5-kio/files/patch-src_ioslaves_file_file__unix.cpp b/devel/kf5-kio/files/patch-src_ioslaves_file_file__unix.cpp -new file mode 100644 -index 000000000000..2898beb65703 ---- /dev/null -+++ b/devel/kf5-kio/files/patch-src_ioslaves_file_file__unix.cpp -@@ -0,0 +1,38 @@ -+--- src/ioslaves/file/file_unix.cpp.orig 2021-05-06 17:50:59 UTC -++++ 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, co -+ -+ 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; -+ } --- -cgit v1.2.3 - diff --git a/debian/patches/series b/debian/patches/series index f52893d..264a806 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -2,4 +2,7 @@ fix_kfreebsd_build fix_hurd_build.patch #Use-CXX_FLAGS-for-moc_predefs.h.patch -kio-upstream-patches-from-freebsd +0001-MimeTypeFinderJob-Resolve-symlinks-for-a-local-file.patch +0002-kio_file-pass-the-absolute-path-to-QMimeDatabase-mim.patch +0003-MimeTypeFinderJob-the-StatJob-details-should-include.patch +0004-kio_file-fix-how-createUDSEntry-is-called.patch