Bug 435675 - File association is overriding http(s)/ftp links in konsole
Summary: File association is overriding http(s)/ftp links in konsole
Status: CONFIRMED
Alias: None
Product: konsole
Classification: Applications
Component: general (show other bugs)
Version: 21.03.90
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-04-12 23:41 UTC by Justin Zobel
Modified: 2022-01-01 00:08 UTC (History)
5 users (show)

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


Attachments
Screenshot (77.18 KB, image/png)
2021-04-14 22:36 UTC, Justin Zobel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Justin Zobel 2021-04-12 23:41:54 UTC
STEPS TO REPRODUCE
1. Set .html to open in kate
2. Paste a link with HTTP://some.link/somefile.html in konsole and open it

OBSERVED RESULT
Link opens in kate

EXPECTED RESULT
Link should be checked to see if it's a web link and open in browser or associated ftp/http application.

- Check prefix
-- if /home/justin/some.html file is local, open in kate
-- if file:/// file is likely local, open in kate
-- if http/ftp/https open in associated application
-- if sshfs etc open in kate as user is likely editing

SOFTWARE/OS VERSIONS
Operating System: Solus 4.2
KDE Plasma Version: 5.21.3
KDE Frameworks Version: 5.80.0
Qt Version: 5.15.2
Kernel Version: 5.11.12-177.current
Comment 1 Nate Graham 2021-04-13 21:48:34 UTC
Can reproduce.
Comment 2 Nate Graham 2021-04-14 00:47:12 UTC
I did some investigation and found the bug is actually in Konsole, somewhere in FileFilterHotSpot::activate(). Determining which app to open the URL with is done in Konsole itself; by the time we get to KIO, we already have an app to launch, and in this circumstance, it's the text editor rather than the web browser. FileFilterHotSpot::activate() does a bunch of fancy processing to figure out which app to open, and it's going wrong somewhere in there.
Comment 3 Justin Zobel 2021-04-14 02:13:09 UTC
Thanks for the investigating Nate!

On Wed, Apr 14, 2021 at 10:17 AM Nate Graham <bugzilla_noreply@kde.org> wrote:
>
> https://bugs.kde.org/show_bug.cgi?id=435675
>
> Nate Graham <nate@kde.org> changed:
>
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>           Component|general                     |general
>             Product|frameworks-kio              |konsole
>             Version|unspecified                 |21.03.90
>            Assignee|kio-bugs-null@kde.org       |konsole-devel@kde.org
>                  CC|                            |tcanabrava@kde.org
>
> --- Comment #2 from Nate Graham <nate@kde.org> ---
> I did some investigation and found the bug is actually in Konsole, somewhere in
> FileFilterHotSpot::activate(). Determining which app to open the URL with is
> done in Konsole itself; by the time we get to KIO, we already have an app to
> launch, and in this circumstance, it's the text editor rather than the web
> browser. FileFilterHotSpot::activate() does a bunch of fancy processing to
> figure out which app to open, and it's going wrong somewhere in there.
>
> --
> You are receiving this mail because:
> You reported the bug.
Comment 4 Ahmad Samir 2021-04-14 05:07:34 UTC
I couldn't reproduce this issue.

Note that http/ftp links aren't supposed to go through FileFilterHotSpot at all, since they're links, so UrlFilterHotspot.
Comment 5 Jonathan Marten 2021-04-14 19:12:39 UTC
The behavious of opening http/https links may have been inadvertently changed by https://invent.kde.org/network/konqueror/-/merge_requests/67.  Are you able to you investigate:

1. With the link that exhibits the anomalous behaviour in Konsole, execute "kfmclient openURL <URL>" with the same URL and see if the behaviour is the same.

2. Check whether $XDG_CONFIG_HOME/kdeglobals contains an entry
[General]
BrowserApplication=...

3. Check whether there are any debug messages from ClientApp::createNewWindow() in ~/.xsession-errors or similar (you may need to enable debug info for the "org.kde.kfmclient" category).
Comment 6 Justin Zobel 2021-04-14 22:35:47 UTC
(In reply to Jonathan Marten from comment #5)
> The behavious of opening http/https links may have been inadvertently
> changed by https://invent.kde.org/network/konqueror/-/merge_requests/67. 
> Are you able to you investigate:
> 
> 1. With the link that exhibits the anomalous behaviour in Konsole, execute
> "kfmclient openURL <URL>" with the same URL and see if the behaviour is the
> same.
> 
> 2. Check whether $XDG_CONFIG_HOME/kdeglobals contains an entry
> [General]
> BrowserApplication=...
> 
> 3. Check whether there are any debug messages from
> ClientApp::createNewWindow() in ~/.xsession-errors or similar (you may need
> to enable debug info for the "org.kde.kfmclient" category).

1. This opened the URL (https://letsencrypt.org/donate) in konqueror but with a dialog above it asking where I'd like to open it (will attach after this comment)

2. $XDG_CONFIG_HOME doesn't have any value. (I did echo $XDG_CONFIG_HOME to check). In ~/.config/kdeglobals there's no BrowserApplication= setting under [General]

3. ~/.xsession-errors is empty. Can you please provide info on how to enable debugging as mentioned?
Comment 7 Justin Zobel 2021-04-14 22:36:04 UTC
Created attachment 137615 [details]
Screenshot
Comment 8 Jonathan Marten 2021-04-16 11:41:13 UTC
Thanks Justin for the investigation.  If there is no [General]BrowserApplication key then the problem is not likely to be a result of the MR above.

When you say "Set .html to open in kate", presumably you mean moving Kate to the top of the list in System Settings - Personalisation - Applications - File Associations for text/html.  If you have done this, have you also set up "Web browser" in Applications - Default Applications?  This should set [General]BrowserApplication in kdeglobals, and please then verify if the behaviour is the same.
Comment 9 Justin Zobel 2021-04-16 23:24:27 UTC
(In reply to Jonathan Marten from comment #8)
> Thanks Justin for the investigation.  If there is no
> [General]BrowserApplication key then the problem is not likely to be a
> result of the MR above.
> 
> When you say "Set .html to open in kate", presumably you mean moving Kate to
> the top of the list in System Settings - Personalisation - Applications -
> File Associations for text/html.  If you have done this, have you also set
> up "Web browser" in Applications - Default Applications?  This should set
> [General]BrowserApplication in kdeglobals, and please then verify if the
> behaviour is the same.

OK interesting. I went into Settings > Applications > Default Applications and saw that Firefox was already set as the default. However, I saw the email client was set to Vivaldi and changed that to Thunderbird and hit apply. I got curious after that and re-tested in konsole and it works correctly now. And now there is an entry in ~/.config/kdeglobals with BrowserApplication=firefox.desktop.

Should the ~/.config/kdeglobals always have that BrowserApplication= setting in it by default?
Comment 10 Justin Zobel 2021-04-16 23:25:19 UTC
I assume then that changing one setting in the Default Applications pane made Settings write all of the four default applications into the config file.
Comment 11 Jonathan Marten 2021-04-17 19:50:44 UTC
> Should the ~/.config/kdeglobals always have that BrowserApplication= setting
> in it by default?

No, but if it is not set then passing a http/https URL to kfmclient will always open Konqueror rather than the configured MIME type association.
Comment 12 Justin Zobel 2022-01-01 00:08:52 UTC
I've tested this on 21.08.3 and I'm not even able to click a https link with primary mouse button. I can right click and "Open Link" which works and opens in my default browser. Can anyone else confirm?