public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Andreas Sturmlechner" <asturm@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: kde-frameworks/kio/files/, kde-frameworks/kio/
Date: Thu, 15 Oct 2020 18:48:46 +0000 (UTC)	[thread overview]
Message-ID: <1602787718.832c3dcb83419e97aa34f7cd2b48f0d23e785b15.asturm@gentoo> (raw)

commit:     832c3dcb83419e97aa34f7cd2b48f0d23e785b15
Author:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 15 18:44:28 2020 +0000
Commit:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
CommitDate: Thu Oct 15 18:48:38 2020 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=832c3dcb

kde-frameworks/kio: Fix regression on selecting files with `#`

See also: https://mail.kde.org/pipermail/distributions/2020-October/000873.html

Package-Manager: Portage-3.0.8, Repoman-3.0.1
Signed-off-by: Andreas Sturmlechner <asturm <AT> gentoo.org>

 ...io-5.75.0-fix-special-char-file-selection.patch | 201 +++++++++++++++++++++
 kde-frameworks/kio/kio-5.75.0-r1.ebuild            |  96 ++++++++++
 2 files changed, 297 insertions(+)

diff --git a/kde-frameworks/kio/files/kio-5.75.0-fix-special-char-file-selection.patch b/kde-frameworks/kio/files/kio-5.75.0-fix-special-char-file-selection.patch
new file mode 100644
index 00000000000..74ffc55207d
--- /dev/null
+++ b/kde-frameworks/kio/files/kio-5.75.0-fix-special-char-file-selection.patch
@@ -0,0 +1,201 @@
+From 4321b8ff8ac7a8ffdea1068d8bbc734a0a34c0d0 Mon Sep 17 00:00:00 2001
+From: Andreas Bontozoglou <a.bontozoglou@gmail.com>
+Date: Wed, 14 Oct 2020 15:01:02 +0100
+Subject: [PATCH] [BUG] Fixing regression on selecting files that contain `#`
+
+Introduced in tokenize() in https://invent.kde.org/frameworks/kio/-/merge_requests/89.
+Fixing by using setPath and adding test-case for parsing such filenames.
+---
+ autotests/kfilewidgettest.cpp   | 37 +++++++++++++++++++--------------
+ src/filewidgets/kfilewidget.cpp | 31 +++++++++++++++------------
+ 2 files changed, 39 insertions(+), 29 deletions(-)
+
+diff --git a/autotests/kfilewidgettest.cpp b/autotests/kfilewidgettest.cpp
+index 859ea958..ac34e387 100644
+--- a/autotests/kfilewidgettest.cpp
++++ b/autotests/kfilewidgettest.cpp
+@@ -24,6 +24,7 @@
+ #include <QAbstractItemView>
+ #include <QDropEvent>
+ #include <QMimeData>
++#include <QStringList>
+ #include <QStringLiteral>
+ #include <QList>
+ #include <QUrl>
+@@ -530,58 +531,62 @@ private Q_SLOTS:
+     }
+ 
+     void testTokenize_data()
+-    {   
+-        // Real filename (as in how they are stored in the fs) 
+-        QTest::addColumn<QList<QString>>("fileNames");
++    {
++        // Real filename (as in how they are stored in the fs)
++        QTest::addColumn<QStringList>("fileNames");
+         // Escaped value of the text-box in the dialog
+         QTest::addColumn<QString>("expectedCurrentText");
+ 
+-        QTest::newRow("simple") << QList<QString>{"test2"} << QString("test2");
++        QTest::newRow("simple") << QStringList{"test2"} << QString("test2");
+ 
+         // When a single file with space is selected, it is _not_ quoted ...
+-        QTest::newRow("space-single-file") 
+-            << QList<QString>{"test space"} 
++        QTest::newRow("space-single-file")
++            << QStringList{"test space"}
+             << QString("test space");
+ 
+         // However, when multiple files are selected, they are quoted
+         QTest::newRow("space-multi-file")
+-            << QList<QString>{"test space", "test2"} 
++            << QStringList{"test space", "test2"}
+             << QString("\"test space\" \"test2\"");
+ 
+         // All quotes in names should be escaped, however since this is a single
+         // file, the whole name will not be escaped.
+         QTest::newRow("quote-single-file")
+-            << QList<QString>{"test\"quote"} 
++            << QStringList{"test\"quote"}
+             << QString("test\\\"quote");
+-        
++
+         // Escape multiple files. Files should also be wrapped in ""
+         // Note that we are also testing quote at the end of the name
+         QTest::newRow("quote-multi-file")
+-            << QList<QString>{"test\"quote", "test2-quote\"", "test"} 
++            << QStringList{"test\"quote", "test2-quote\"", "test"}
+             << QString("\"test\\\"quote\" \"test2-quote\\\"\" \"test\"");
+ 
+         // Ok, enough with quotes... lets do some backslashes
+         // Backslash literals in file names - Unix only case
+         QTest::newRow("backslash-single-file")
+-            << QList<QString>{"test\\backslash"} 
++            << QStringList{"test\\backslash"}
+             << QString("test\\\\backslash");
+ 
+         QTest::newRow("backslash-multi-file")
+-            << QList<QString>{"test\\back\\slash", "test"} 
++            << QStringList{"test\\back\\slash", "test"}
+             << QString("\"test\\\\back\\\\slash\" \"test\"");
+ 
+         QTest::newRow("double-backslash-multi-file")
+-            << QList<QString>{"test\\\\back\\slash", "test"} 
++            << QStringList{"test\\\\back\\slash", "test"}
+             << QString("\"test\\\\\\\\back\\\\slash\" \"test\"");
+ 
+         QTest::newRow("double-backslash-end")
+-            << QList<QString>{"test\\\\"} 
++            << QStringList{"test\\\\"}
+             << QString("test\\\\\\\\");
+ 
+         QTest::newRow("single-backslash-end")
+-            << QList<QString>{"some thing", "test\\"} 
++            << QStringList{"some thing", "test\\"}
+             << QString("\"some thing\" \"test\\\\\"");
+ 
++        QTest::newRow("sharp")
++            << QStringList{"some#thing"}
++            << QString("some#thing");
++
+     }
+ 
+     void testTokenize()
+@@ -589,7 +594,7 @@ private Q_SLOTS:
+         // We will use setSelectedUrls([QUrl]) here in order to check correct
+         // filename escaping. Afterwards we will accept() the dialog to confirm
+         // correct result
+-        QFETCH(QList<QString>, fileNames);
++        QFETCH(QStringList, fileNames);
+         QFETCH(QString, expectedCurrentText);
+ 
+         QTemporaryDir tempDir;
+diff --git a/src/filewidgets/kfilewidget.cpp b/src/filewidgets/kfilewidget.cpp
+index 1bbf3e58..32ca0617 100644
+--- a/src/filewidgets/kfilewidget.cpp
++++ b/src/filewidgets/kfilewidget.cpp
+@@ -789,8 +789,8 @@ static QString relativePathOrUrl(const QUrl &baseUrl, const QUrl &url);
+ /**
+  * Escape the given Url so that is fit for use in the selected list of file. This
+  * mainly handles double quote (") characters. These are used to separate entries
+- * in the list, however, if `"` appears in the filename (or path), this will be 
+- * escaped as `\"`. Later, the tokenizer is able to understand the difference 
++ * in the list, however, if `"` appears in the filename (or path), this will be
++ * escaped as `\"`. Later, the tokenizer is able to understand the difference
+  * and do the right thing
+  */
+ static QString escapeDoubleQuotes(QString && path);
+@@ -1623,7 +1623,7 @@ void KFileWidget::setSelectedUrl(const QUrl &url)
+ }
+ 
+ void KFileWidget::setSelectedUrls(const QList<QUrl> &urls)
+-{   
++{
+     if (urls.isEmpty()) {
+         return;
+     }
+@@ -1717,7 +1717,7 @@ QList<QUrl> KFileWidget::selectedUrls() const
+ 
+ QList<QUrl> KFileWidgetPrivate::tokenize(const QString &line) const
+ {
+-    qCDebug(KIO_KFILEWIDGETS_FW) << "Tokenizing:" << line; 
++    qCDebug(KIO_KFILEWIDGETS_FW) << "Tokenizing:" << line;
+ 
+     QList<QUrl> urls;
+     QUrl u(ops->url().adjusted(QUrl::RemoveFilename));
+@@ -1727,15 +1727,21 @@ QList<QUrl> KFileWidgetPrivate::tokenize(const QString &line) const
+ 
+     // A helper that creates, validates and appends a new url based
+     // on the given filename.
+-    auto addUrl = [u, &urls](const QString & partial_name) 
+-    { 
++    auto addUrl = [u, &urls](const QString &partial_name)
++    {
+         if (partial_name.trimmed().isEmpty()) {
+             return;
+         }
+ 
++        // We have to use setPath here, so that something like "test#file"
++        // isn't interpreted to have path "test" and fragment "file".
++        QUrl partial_url;
++        partial_url.setPath(partial_name);
++
+         // This returns QUrl(partial_name) for absolute URLs.
+         // Otherwise, returns the concatenated url.
+-        QUrl finalUrl = u.resolved(QUrl(partial_name));
++        const QUrl finalUrl = u.resolved(partial_url);
++
+         if (finalUrl.isValid()) {
+             urls.append(finalUrl);
+         } else {
+@@ -1758,7 +1764,7 @@ QList<QUrl> KFileWidgetPrivate::tokenize(const QString &line) const
+             escape = false;
+             continue;
+         }
+-        
++
+         // Handle escape start
+         if (ch.toLatin1() == '\\') {
+             escape = true;
+@@ -1777,15 +1783,14 @@ QList<QUrl> KFileWidgetPrivate::tokenize(const QString &line) const
+         partial_name += ch;
+     }
+ 
+-    // Handle the last item which is buffered in 
+-    // partial_name. This is required for single-file
+-    // selection dialogs since the name will not be 
+-    // wrapped in quotes
++    // Handle the last item which is buffered in partial_name. This is
++    // required for single-file selection dialogs since the name will not
++    // be wrapped in quotes
+     if (!partial_name.isEmpty()) {
+         addUrl(partial_name);
+         partial_name.clear();
+     }
+-    
++
+     return urls;
+ }
+ 
+-- 
+GitLab
+

diff --git a/kde-frameworks/kio/kio-5.75.0-r1.ebuild b/kde-frameworks/kio/kio-5.75.0-r1.ebuild
new file mode 100644
index 00000000000..310bd84b0a4
--- /dev/null
+++ b/kde-frameworks/kio/kio-5.75.0-r1.ebuild
@@ -0,0 +1,96 @@
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+ECM_DESIGNERPLUGIN="true"
+ECM_TEST="forceoptional"
+PVCUT=$(ver_cut 1-2)
+QTMIN=5.14.2
+VIRTUALX_REQUIRED="test"
+inherit ecm kde.org xdg-utils
+
+DESCRIPTION="Framework providing transparent file and data management"
+LICENSE="LGPL-2+"
+KEYWORDS="~amd64 ~arm ~arm64 ~ppc64 ~x86"
+IUSE="acl +handbook kerberos +kwallet X"
+
+# drop qtnetwork subslot operator when QT_MINIMAL >= 5.15.0
+RDEPEND="
+	dev-libs/libxml2
+	dev-libs/libxslt
+	>=dev-qt/qtdbus-${QTMIN}:5
+	>=dev-qt/qtdeclarative-${QTMIN}:5
+	>=dev-qt/qtgui-${QTMIN}:5
+	>=dev-qt/qtnetwork-${QTMIN}:5=[ssl]
+	>=dev-qt/qtwidgets-${QTMIN}:5
+	>=dev-qt/qtxml-${QTMIN}:5
+	=kde-frameworks/kauth-${PVCUT}*:5
+	=kde-frameworks/karchive-${PVCUT}*:5
+	=kde-frameworks/kbookmarks-${PVCUT}*:5
+	=kde-frameworks/kcodecs-${PVCUT}*:5
+	=kde-frameworks/kcompletion-${PVCUT}*:5
+	=kde-frameworks/kconfig-${PVCUT}*:5
+	=kde-frameworks/kconfigwidgets-${PVCUT}*:5
+	=kde-frameworks/kcoreaddons-${PVCUT}*:5
+	=kde-frameworks/kcrash-${PVCUT}*:5
+	=kde-frameworks/kdbusaddons-${PVCUT}*:5
+	=kde-frameworks/ki18n-${PVCUT}*:5
+	=kde-frameworks/kiconthemes-${PVCUT}*:5
+	=kde-frameworks/kitemviews-${PVCUT}*:5
+	=kde-frameworks/kjobwidgets-${PVCUT}*:5
+	=kde-frameworks/knotifications-${PVCUT}*:5
+	=kde-frameworks/kservice-${PVCUT}*:5
+	=kde-frameworks/ktextwidgets-${PVCUT}*:5
+	=kde-frameworks/kwidgetsaddons-${PVCUT}*:5
+	=kde-frameworks/kwindowsystem-${PVCUT}*:5
+	=kde-frameworks/kxmlgui-${PVCUT}*:5
+	=kde-frameworks/solid-${PVCUT}*:5
+	acl? (
+		sys-apps/attr
+		virtual/acl
+	)
+	handbook? ( =kde-frameworks/kdoctools-${PVCUT}*:5 )
+	kerberos? ( virtual/krb5 )
+	kwallet? ( =kde-frameworks/kwallet-${PVCUT}*:5 )
+	X? ( >=dev-qt/qtx11extras-${QTMIN}:5 )
+"
+DEPEND="${RDEPEND}
+	>=dev-qt/qtconcurrent-${QTMIN}:5
+	test? ( sys-libs/zlib )
+	X? (
+		x11-base/xorg-proto
+		x11-libs/libX11
+		x11-libs/libXrender
+	)
+"
+PDEPEND="
+	>=kde-frameworks/kded-${PVCUT}:5
+"
+
+# tests hang
+RESTRICT+=" test"
+
+PATCHES=( "${FILESDIR}"/${P}-fix-special-char-file-selection.patch )
+
+src_configure() {
+	local mycmakeargs=(
+		$(cmake_use_find_package acl ACL)
+		$(cmake_use_find_package handbook KF5DocTools)
+		$(cmake_use_find_package kerberos GSSAPI)
+		$(cmake_use_find_package kwallet KF5Wallet)
+		$(cmake_use_find_package X X11)
+	)
+
+	ecm_src_configure
+}
+
+pkg_postinst() {
+	ecm_pkg_postinst
+	xdg_desktop_database_update
+}
+
+pkg_postrm() {
+	ecm_pkg_postrm
+	xdg_desktop_database_update
+}


             reply	other threads:[~2020-10-15 18:48 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-15 18:48 Andreas Sturmlechner [this message]
  -- strict thread matches above, loose matches on Subject: below --
2023-12-25 19:51 [gentoo-commits] repo/gentoo:master commit in: kde-frameworks/kio/files/, kde-frameworks/kio/ Andreas Sturmlechner
2023-12-25 19:51 Andreas Sturmlechner
2023-09-19 10:40 Andreas Sturmlechner
2023-04-22 16:21 Andreas Sturmlechner
2023-02-18 23:05 Andreas Sturmlechner
2023-01-30 21:43 Andreas Sturmlechner
2022-06-29 19:53 Andreas Sturmlechner
2022-02-10  9:13 Andreas Sturmlechner
2021-11-05 16:24 Andreas Sturmlechner
2021-09-14  9:04 Andreas Sturmlechner
2021-08-15 18:57 Andreas Sturmlechner
2021-07-11 20:47 Andreas Sturmlechner
2021-04-04 13:23 Andreas Sturmlechner
2021-02-03 22:33 Andreas Sturmlechner
2020-09-29 12:49 Andreas Sturmlechner
2020-05-16  9:08 Andreas Sturmlechner
2020-05-15  8:16 Andreas Sturmlechner
2020-02-09 22:28 Andreas Sturmlechner
2019-12-22 22:48 Andreas Sturmlechner
2019-12-19  9:45 Andreas Sturmlechner
2019-01-12 14:35 Andreas Sturmlechner
2018-11-27  7:49 Andreas Sturmlechner
2017-11-29 16:40 Andreas Sturmlechner
2017-11-26 18:57 Andreas Sturmlechner
2017-05-29 22:58 Andreas Sturmlechner
2016-09-29 11:39 Michael Palimaka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1602787718.832c3dcb83419e97aa34f7cd2b48f0d23e785b15.asturm@gentoo \
    --to=asturm@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox