[PATCH] applets/kicker: fix filenames containing # in history
authorChristoph Wolk <cwo.kde@posteo.net>
Thu, 5 Jun 2025 18:33:29 +0000 (18:33 +0000)
committerAurélien COUDERC <coucouf@debian.org>
Mon, 21 Jul 2025 16:21:10 +0000 (18:21 +0200)
Kicker takes the resource name as provided by PlasmaActivities.Stats and
interprets it as an URL, setting the 'file' url scheme if necessary.
This fails when the filenames contain a '#' character, as QUrl will
interpret them as url fragments if not percent-encoded (which they are
not for local files, but are for remote urls). This makes display and
opening of such files fail in both Kicker and Kickoff.

Instead, we test whether it's an absolute path (the local history
entries are) and if so, use QUrl.fromLocalFile to get the correct url.
This is also what PlasmaActivities.Stats does in ResultSet (which is
what the Task Manager uses, so everything works there already, but we
want a real model here).

BUG: 419449
BUG: 437960
FIXED-IN: 6.4.0

(cherry picked from commit c6c0a68416b5042032853a6f673bddbe475567b7)

Co-authored-by: Christoph Wolk <cwo.kde@posteo.net>
Gbp-Pq: Name upstream_ab55c53e_applets-kicker-fix-filenames-containing-in-history.patch

applets/kicker/plugin/recentusagemodel.cpp

index c0c7466e82bd8b22c9bfc258d0fb9608e8488fbb..45462695779534415fe7cb4b0f5509e040b0f939 100644 (file)
@@ -273,10 +273,12 @@ QModelIndex RecentUsageModel::findPlaceForKFileItem(const KFileItem &fileItem) c
 
 QVariant RecentUsageModel::docData(const QString &resource, int role, const QString &mimeType) const
 {
-    QUrl url(resource);
+    QUrl url;
 
-    if (url.scheme().isEmpty()) {
-        url.setScheme(QStringLiteral("file"));
+    if (QDir::isAbsolutePath(resource)) {
+        url = QUrl::fromLocalFile(resource);
+    } else {
+        url = QUrl(resource);
     }
 
     auto getFileItem = [=]() {