Bug 457685 - Local recent files in non-KDE apps are opened using kio-fuse mounted location instead of local path
Summary: Local recent files in non-KDE apps are opened using kio-fuse mounted location...
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: general (other bugs)
Version First Reported In: 5.96.0
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: KIO Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-08-09 16:56 UTC by Igor Poboiko
Modified: 2022-08-13 14:09 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Igor Poboiko 2022-08-09 16:56:51 UTC
SUMMARY & STEPS TO REPRODUCE
I have a TeXStudio icon pinned to the taskbar.
It has "Recent files" list available via right-mouse-click menu, with bunch of files, all inside local filesystem (e.g. inside my home directory).
When I open one of those files via the menu, they are opened using the path "/run/user/UID/kio-fuse-XXXXXX/file/home/user/...", instead of simple "/home/user/...". I suppose it shouldn't happen.

This issue also interferes with built-in "Recent files" feature available in some of the apps: two entries appear there, one of which pointing to the local path (/home/user/...), and other pointing to temporary kiofuse URL. The later also becomes unavailable after reboot.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Gentoo Linux 2.8
KDE Plasma Version: 5.25.3
KDE Frameworks Version: 5.96.0
Qt Version: 5.15.5

ADDITIONAL INFORMATION
 - The issue is not specific to TeXStudio: apparently, all non-KDE apps are affected: tested also with LyX and Wolfram Mathematica. KDE apps behave correctly (tested with Okular, Kate).
 - I suppose that "Recent files" are extracted from "~/.local/share/recently-used.xbel" file, which contains URLs both in format href="file:///home/user/..." and href="/home/user/...". Both types are however opened inside kio-fuse mounted path instead of local one.
Comment 1 Fabian Vogt 2022-08-09 17:42:34 UTC
Yep, I can reproduce the issue. Here I edited kate's desktop file to use %f instead of %U and it uses kio-fuse.

Reassigning to kio, which decides which URLs to hand over to kio-fuse.
Comment 2 Fabian Vogt 2022-08-09 18:01:03 UTC
The issue appears to be caused by whatever writes into the recently-used.xbel file. In some cases it stores a file path instead of a URL in the "href" attribute, which is treated as a URL by KIO. QUrl("/file/path") has an empty scheme() and isLocalFile() returns false, so it passes the not-really-URL to kio-fuse. kio-fuse in turn uses QUrl::fromUserInput which is smart enough to recognize that it's in fact a local path and converts it to a proper file:// URL internally. That's why it works at all...
Comment 3 Bug Janitor Service 2022-08-09 18:47:25 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/2008
Comment 4 Fabian Vogt 2022-08-09 18:48:51 UTC
Now I can't find a way to reliably get such a broken path into the recently-used.xbel file, so I can't really find out which code path triggers the bad format. I found one candidate though and made a MR for that, but there are probably some other places. KActivities doesn't really distinguish between file paths and URLs unfortunately, it's all just stored as strings.

What doesn't help is that sometimes the context menu entries are broken. In the panel they sometimes do nothing and QML complains about "calling indexOf on undefined". In kicker the entries sometimes do nothing because 'Desktop Entry file "" doesn't have a valid Exec key'.
Comment 5 Bug Janitor Service 2022-08-10 17:23:35 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-desktop/-/merge_requests/1085
Comment 6 Fabian Vogt 2022-08-11 08:46:57 UTC
Git commit bf37558f36494d13f0fe0f00862937d859aa20f1 by Fabian Vogt.
Committed on 11/08/2022 at 08:15.
Pushed by fvogt into branch 'master'.

taskmanager: Use proper QUrls for recent document actions

The resource can either be a URL or an absolute path, the url() method
converts the latter into a proper URL. Without this, a local path might end
up getting parsed (badly) as URL, causing weird behaviour later, like resorting
to kioexec/kio-fuse.

M  +5    -10   applets/taskmanager/plugin/backend.cpp

https://invent.kde.org/plasma/plasma-desktop/commit/bf37558f36494d13f0fe0f00862937d859aa20f1
Comment 7 Fabian Vogt 2022-08-11 08:47:23 UTC
Git commit 24e92862c85cdfee7a0fbe66336b7d259acd86a9 by Fabian Vogt.
Committed on 11/08/2022 at 08:47.
Pushed by fvogt into branch 'Plasma/5.25'.

taskmanager: Use proper QUrls for recent document actions

The resource can either be a URL or an absolute path, the url() method
converts the latter into a proper URL. Without this, a local path might end
up getting parsed (badly) as URL, causing weird behaviour later, like resorting
to kioexec/kio-fuse.


(cherry picked from commit bf37558f36494d13f0fe0f00862937d859aa20f1)

M  +5    -10   applets/taskmanager/plugin/backend.cpp

https://invent.kde.org/plasma/plasma-desktop/commit/24e92862c85cdfee7a0fbe66336b7d259acd86a9
Comment 8 Igor Poboiko 2022-08-11 14:58:12 UTC
I've rebuild the plasma-desktop with the patch applied, seems like it fixed the issue for me. Thanks!
Comment 9 Fabian Vogt 2022-08-11 16:22:20 UTC
Git commit d2e3f679cfc81a22c85cbe58fb4fbf570149ed64 by Fabian Vogt.
Committed on 11/08/2022 at 16:10.
Pushed by fvogt into branch 'master'.

Create proper QUrls for recent document actions

The resource can either be a URL or an absolute path, the url() method
converts the latter into a proper URL.

M  +1    -2    applets/kicker/plugin/actionlist.cpp

https://invent.kde.org/plasma/plasma-workspace/commit/d2e3f679cfc81a22c85cbe58fb4fbf570149ed64
Comment 10 Fabian Vogt 2022-08-11 17:11:55 UTC
(In reply to Igor Poboiko from comment #8)
> I've rebuild the plasma-desktop with the patch applied, seems like it fixed
> the issue for me. Thanks!

Yay, thanks for confirming!

(In reply to Fabian Vogt from comment #4)
> What doesn't help is that sometimes the context menu entries are broken. In
> the panel they sometimes do nothing and QML complains about "calling indexOf
> on undefined". In kicker the entries sometimes do nothing because 'Desktop
> Entry file "" doesn't have a valid Exec key'.

Turns out this URL confusion bug is actually the cause for both the invalid URLs in recently-used.xbel as well as this weird behaviour that the menu entries sometimes don't work. When using one of those broken entries for the first time, the broken URL is put into the recently-used.xbel file as well as into the kactivitymanagerd database. The latter also saves the mime type of the file, but with the broken URL that failed and it used application/octet-stream as fallback. When using one of those (now doubly-broken!) items, Plasma notices that the application doesn't support the mime type of the recently used file entry and refuses to launch it.
Comment 11 Fabian Vogt 2022-08-13 14:09:09 UTC
Git commit 615c286f3be390fa6dc5eb39f139ddf7bf39c2f1 by Fabian Vogt.
Committed on 13/08/2022 at 14:05.
Pushed by fvogt into branch 'Plasma/5.24'.

taskmanager: Use proper QUrls for recent document actions

The resource can either be a URL or an absolute path, the url() method
converts the latter into a proper URL. Without this, a local path might end
up getting parsed (badly) as URL, causing weird behaviour later, like resorting
to kioexec/kio-fuse.

Plasma/5.24 backport note: Here it doesn't request URLs, so the resource is
actually never a valid URL!
(cherry picked from commit bf37558f36494d13f0fe0f00862937d859aa20f1)

M  +5    -7    applets/taskmanager/plugin/backend.cpp

https://invent.kde.org/plasma/plasma-desktop/commit/615c286f3be390fa6dc5eb39f139ddf7bf39c2f1