Bug 439477 - Clicking on links in Qt/KDE apps causes the website to be cached, rather than the link being forwarded to the browser
Summary: Clicking on links in Qt/KDE apps causes the website to be cached, rather than...
Status: REOPENED
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 5.103.0
Platform: Manjaro Linux
: NOR grave
Target Milestone: ---
Assignee: KIO Bugs
URL:
Keywords:
: 479580 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-07-04 14:29 UTC by geisserml
Modified: 2024-03-20 23:34 UTC (History)
11 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.85


Attachments
Screenshot illustrating the problem (398.81 KB, image/png)
2021-07-04 14:31 UTC, geisserml
Details
/usr/share/applications/ (8.34 KB, application/x-desktop)
2023-02-20 15:19 UTC, mail.orb
Details
~/.local/share/applications (8.28 KB, application/x-desktop)
2023-02-20 15:20 UTC, mail.orb
Details

Note You need to log in before you can comment on or make changes to this bug.
Description geisserml 2021-07-04 14:29:08 UTC
SUMMARY

When clicking a link in a Qt/KDE app on Plasma, the website is downloaded to a cache directory (~/.cache/kioexec/krun/) and the local file will be opened in the default browser, rather than the link being forwarded to the browser.

This causes many issues:
- The file is usually displayed as text, not as website
- When recognised as html, images and cross-references to other pages don't work; the website looks damaged
- The cache is never cleaned by the system; the unnecessary files remain. The directory will grow enormously unless users take action.

Links in programs occur very often: In PDFs, in About and Help windows, in markdown preview, and many many more places. Usually, links can be copy/pasted manually into the browser, avoiding the cache. However, sometimes they are not copyable, so there is no possibility to avoid the cache. (For some links, I never found out which websites they were actually pointing to, because the text content didn't tell.)

Websites should never get downloaded and cached, but the links should simply be sent to the browser, like GTK applications such as Thunderbird do.


STEPS TO REPRODUCE
1. Open any Qt/KDE app containing a web link (e. g. Kate -> Help -> About Kate -> Link to the Kate website)
2. Click it

OBSERVED RESULT
- The website will get downloaded to ~/.cache/kioexec/krun/ (a KIO notification with progress bar shows up)
- The default browser will open the file, usually displayed as plain text
- The file will remain across sessions and restarts, unless deleted manually

EXPECTED RESULT
- The link should be sent to the browser without caching.
- The website should load as html, not as text.
- All content should look correct; cross-references should work.

SOFTWARE/OS VERSIONS
Operating System: KDE neon 5.22
KDE Plasma Version: 5.22.2
KDE Frameworks Version: 5.83.0
Qt Version: 5.15.3
Kernel Version: 5.8.0-59-generic (64-bit)
Graphics Platform: Wayland

ADDITIONAL INFORMATION
This didn't happen at the time of Plasma 5.20.
Related:
- https://bugs.kde.org/show_bug.cgi?id=413885
- https://askubuntu.com/questions/1186697/what-uses-and-fills-up-cache-kioexec-krun


WORKAROUND

Save the following Python code to any place you like, make it executable (chmod +x $FILENAME), and define it as logout script to clean the cache directory regularly.


```
#! /usr/bin/env python3

import os
import shutil

HOME = os.path.expanduser('~')
KIO_CACHE = HOME+'/.cache/kioexec/krun/'

def clean_kiocache():
    for file_or_dir in os.listdir(KIO_CACHE):
        cached = KIO_CACHE+file_or_dir
        if os.path.isdir(cached):
            shutil.rmtree(cached)
        else:
            os.remove(cached)

if __name__ == '__main__':
    clean_kiocache()
```

(A normal shell script might have been shorter.)
Comment 1 geisserml 2021-07-04 14:31:45 UTC
Created attachment 139847 [details]
Screenshot illustrating the problem
Comment 2 Ahmad Samir 2021-07-09 17:14:08 UTC
Do you have a default web browser set in systemsettings -> applications -> default applications?
Comment 3 Nate Graham 2021-07-09 17:43:12 UTC
.
Comment 4 geisserml 2021-07-09 19:05:57 UTC
Of course I do. It's Chromium.
Comment 5 geisserml 2021-07-09 19:08:51 UTC
I think this can't be the problem. The default browser is recognised properly, as the cached file is opened in it. Was the description unclear?
Comment 6 Ahmad Samir 2021-07-14 16:18:30 UTC
Looking at https://invent.kde.org/frameworks/kio/-/merge_requests/498

could you check the .desktop file used? (is it the one shipped by chromium or did you select the chromium executable from the open-with dialog in the "default applications" KCM?
Comment 7 geisserml 2021-07-14 17:44:37 UTC
I think I did selected from the open-with dialog of the kcm, so the linked PR is likely to fix the problem. Thanks in advance!
Comment 8 Ahmad Samir 2021-07-14 17:46:16 UTC
Excellent, thanks for feedback :)
Comment 9 geisserml 2021-07-14 19:34:07 UTC
By the way, may I ask why the permanent cache ~/.cache/kioexec/krun/ exists at all? Wouldn't regular tempfiles that are removed at the end of a session make more sense?
Comment 10 Ahmad Samir 2021-07-14 19:39:56 UTC
(In reply to Manuel Geißer from comment #9)
> By the way, may I ask why the permanent cache ~/.cache/kioexec/krun/ exists
> at all? Wouldn't regular tempfiles that are removed at the end of a session
> make more sense?

That's a good point, could you open a bug report to track that issue? :)
Comment 11 geisserml 2021-07-15 11:09:25 UTC
Yeah, I'll do that.
Comment 12 geisserml 2021-07-15 12:19:35 UTC
https://bugs.kde.org/show_bug.cgi?id=439886
Comment 13 geisserml 2021-11-21 10:31:38 UTC
Unfortunately, this bug got back with kf5 updates. It was fixed for some time, but now I have the same problem again.
Comment 14 shenlebantongying 2022-01-28 19:57:20 UTC
I can confirm that this bug can be reproduced by removing "%u" in the exec line from the `firefox.desktop` file.

I was changing that line to enforce some settings, and I thought %u is useless "bureaucracy". Appending %u back to that line solved the problem for me.

I am on using KDE from archlinux's unstable repo.

Operating System: Arch Linux
KDE Plasma Version: 5.23.90
KDE Frameworks Version: 5.90.0
Qt Version: 5.15.2
Comment 15 ziesv4tii 2022-05-20 19:20:38 UTC
I wanted to comment. I started having this issue recently.
Comment 16 Ahmad Samir 2022-05-20 19:30:37 UTC
(In reply to ziesv4tii from comment #15)
> I wanted to comment. I started having this issue recently.

Looking at comment#14, that could be a misconfiguration issue; could you post the contents of the actual .desktop file being used? mostly likely it's in:
- /usr/share/applications/ OR
- /usr/local/share/applications/ OR
- ~/.local/share/applications

with the last one taking precedence.
Comment 17 mail.orb 2023-02-20 15:19:41 UTC
Created attachment 156535 [details]
/usr/share/applications/
Comment 18 mail.orb 2023-02-20 15:20:43 UTC
Created attachment 156536 [details]
~/.local/share/applications
Comment 19 mail.orb 2023-02-20 15:23:45 UTC
Also got this issue recently, it downloads urls instead opening in web browser.

example open kate in terminal > about > click url

kate
command= "/usr/bin/brave-beta --use-gl=desktop --enable-features=VaapiVideoDecoder --disable-features=UseChromeOSDirectVideoDecoder" args= ("/usr/bin/brave-beta --use-gl=desktop --enable-features=VaapiVideoDecoder --disable-features=UseChromeOSDirectVideoDecoder", "https://kate-editor.org")
kf.kio.core: Protocol Class of url QUrl("https://kate-editor.org") , isn't ':local', cancelling job.
Copying QUrl("https://kate-editor.org")  to QUrl("file:///home/rob/.cache/kioexec/krun/15485_0/unnamed")
All files downloaded, will call slotRunApp shortly
No files downloaded -> exiting
A KUiServerV2JobTracker instance contains 1 stalled jobs
Comment 20 dE 2023-04-09 06:29:13 UTC
Affected for a long long time. Gentoo.
Comment 21 Nicolas Fella 2023-05-18 16:54:27 UTC
As https://bugs.kde.org/show_bug.cgi?id=439477#c14 already found out this thing happens when the relevant .desktop file is missing the %u  placeholder. This can be either because upstream does not include it or it was manually removed
Comment 22 fanzhuyifan 2024-01-09 20:41:56 UTC
*** Bug 479580 has been marked as a duplicate of this bug. ***
Comment 23 silocoder 2024-03-20 18:41:17 UTC
Hello, I am having this same problem using the Viber app (a messaging app). https://www.viber.com/en/download/
Operating System: Kubuntu 23.10
KDE Plasma Version: 5.27.8
KDE Frameworks Version: 5.110.0
Qt Version: 5.15.10

When I click on a link  it will give the following debug message. Maybe it can point to the issue or workaround.

```
command= "env GTK_USE_PORTAL=1 /usr/bin/google-chrome-stable" args= ("env GTK_USE_PORTAL=1 /usr/bin/google-chrome-stable", "https://www.yahoo.com/")
kf.kio.core: Protocol Class of url QUrl("https://www.yahoo.com/") , isn't ':local', cancelling job.
Copying QUrl("https://www.yahoo.com/")  to QUrl("file:///home/user1/.cache/kioexec/krun/42229_0/unnamed")
Telling kioexecd to watch path "/home/user1/.cache/kioexec/krun/42229_0/unnamed" dest "https://www.yahoo.com/"
All files downloaded, will call slotRunApp shortly
EXEC "/usr/bin/env GTK_USE_PORTAL=1 /usr/bin/google-chrome-stable /home/user1/.cache/kioexec/krun/42229_0/unnamed"
mkdir: /tmp/.mount_viber.jKTZis/usr/lib/libselinux.so.1: no version information available (required by mkdir)
/usr/bin/google-chrome-stable: /tmp/.mount_viber.jKTZis/usr/lib/libnss3.so: version `NSS_3.65' not found (required by /lib/x86_64-linux-gnu/libsmime3.so)
EXEC done
```
Comment 24 silocoder 2024-03-20 18:56:11 UTC
In addition this is my viber.desktop application file.

[Desktop Entry]
Categories=Network;InstantMessaging;P2P;
Comment[en_US]=Viber VoIP and messenger
Comment=Viber VoIP and messenger
Exec=/home/user1/Applications/viber.appimage %u
GenericName[en_US]=
GenericName=
Icon=Viber
MimeType=
Name[en_US]=Viber
Name=Viber
Path=
StartupNotify=true
Terminal=false
TerminalOptions=
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=
X-KDE-SubstituteUID=false
X-KDE-Username=
Comment 25 Nicolas Fella 2024-03-20 18:59:41 UTC
Make sure the *Chrome* desktop file contains the %u placeholder
Comment 26 silocoder 2024-03-20 23:34:58 UTC
(In reply to Nicolas Fella from comment #25)
> Make sure the *Chrome* desktop file contains the %u placeholder

Did try it and even other browsers.

However I tried executing the above EXEC command from the command line, and I get the page raw text. But if I rename 'unnamed' to 'unnamed.html' it works fine:

/usr/bin/env GTK_USE_PORTAL=1 /usr/bin/google-chrome-stable /home/user1/.cache/kioexec/krun/42229_0/unnamed

vs after renaming

/usr/bin/env GTK_USE_PORTAL=1 /usr/bin/google-chrome-stable /home/user1/.cache/kioexec/krun/42229_0/unnamed.html

So it seems to me it has to do with the mimetype? Not sure why the page is being saved in cache with that name anyway. Also is this error related:
mkdir: /tmp/.mount_viber.jKTZis/usr/lib/libselinux.so.1: no version information available (required by mkdir)
/usr/bin/google-chrome-stable: /tmp/.mount_viber.jKTZis/usr/lib/libnss3.so: version `NSS_3.65' not found (required by /lib/x86_64-linux-gnu/libsmime3.so)