Bug 354246

Summary: kde-open5 should open the original URL, not the one it was redirected to
Product: [Plasma] kde-cli-tools Reporter: Francois Gouget <fgouget>
Component: generalAssignee: Aleix Pol <aleixpol>
Status: RESOLVED FIXED    
Severity: normal CC: marco.clemencic, materka, me, minterior, rdieter, scarpino, urmet.saar
Priority: NOR    
Version: 5.4.2   
Target Milestone: ---   
Platform: Debian testing   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Francois Gouget 2015-10-23 09:30:07 UTC
To reproduce this problem run:
kde-open5 "https://www.codeweavers.com/support/bugs/browse/?cmd=bug_edit;bug_id=13370"

* Access to this specific page requires being logged into that website which KDE is not.
* As a result kde-open5 gets redirected to the general browse page:
   https://www.codeweavers.com/support/bugs/browse/
* kde-open5 then notices this is an HTML page and thus invokes iceweasel.
* But it invokes it on the redirected URL, not on the original one.
* So iceweasel opens with the wrong page despite having access to the original URL.

kde-open5 should not make assumptions about redirections and should always pass the original URL to the browser.

Note: I know that a workaround is to tell KDE to invoke iceweasel directly but obviously that means losing the kde-open5 functionality.
Comment 1 Marco Clemencic 2015-11-27 10:05:08 UTC
I have the same problem (with other URLs).
Comment 2 Konrad Materka 2016-07-27 07:47:52 UTC
There are other issues, for example huge delay:
https://bugs.kde.org/show_bug.cgi?id=364662

Also when browser has different proxy configuration it won't work. Problem mentioned above is also very annoying - this redirects are so annoying that I cannot click on links in KDE.

This problem affects Skype (and many other applications) which are using xdg-open to open links. xdg-open uses kde-open5 when KDE session is detected so almost all links I'm working with I need to copy by hand to browser - extremely annoying.
Comment 3 Jaume 2016-11-04 14:56:56 UTC
Having the same issue here. Intranet links clicked within Slack opens in the browser as the login page.
Comment 4 Andrea Scarpino 2017-04-29 15:12:03 UTC

*** This bug has been marked as a duplicate of bug 364662 ***
Comment 5 Konrad Materka 2017-11-06 15:33:28 UTC
This is not a duplicate of bug 364662.

These are two separate cases:
* connection refuse/timeout/etc when KDE is configured with wrong proxy (or any other cause). Usually when browser is configured differently than KDE (for example proxy). It is hard to say if this is a bug or not but this is exactly what was described in bug 364662.
* URL content is behind some kind of authorization, for example link to internal Jira issue. KDE internally follows redirection to login page, then recognizes content as HTML and opens new (redirected) URL in the browser. This is exactly what was described in this bug report.

Please reopen this one. My comment 2 was only to connect both issues, not to mark them as duplicate.
Comment 6 Konrad Materka 2017-11-07 11:30:25 UTC
In fact it is a regression introduced... more than 7 years ago. Please check lines 1393 and 1478:
https://github.com/KDE/kdelibs/blame/fee65b598f0d68ae7b4fbc3f76cb0c083f6d30ef/kio/kio/krun.cpp

Now it is hosted in different repository but history is lost:
https://github.com/KDE/kio/blame/master/src/widgets/krun.cpp
Comment 7 Christoph Feck 2017-11-09 01:24:46 UTC
Reopening based on recent comments.
Comment 8 Rex Dieter 2017-11-28 17:16:46 UTC
fwiw, I don't see the problem on my box, but I have the
systemsettings->web browser default set explicitly, and not the default:
open in application based on the contents of the URL
Comment 9 Aidan Harris 2018-06-11 03:07:54 UTC
I can confirm this bug. Re-production steps for the latest KDE Neon Git Unstable are given below:

1) Boot the iso (this isn't relevant but I tested this in qemu as follows: `qemu-system-x86_64 -enable-kvm -cpu host -vga virtio -m 8G -cdrom neon-devedition-gitunstable-20180605-0736-amd64.iso`)
2) Install Akregator (in Konsole: `sudo apt update`, `sudo apt install akregator`)
3) Open Akregator and "Fetch All Feeds"
4) Right-Click any item and select "Share on Pocket"
5) Note the URL that is opened is https://getpocket.com/login?e=2 instead of https://getpocket.com/save?url={{url}}&title={{title}}

In System Settings (under "Default Applications", "Web Browser") the problem persists when using "in the following application: Firefox Web Browser". Setting the default web browser to "with the following command: /usr/bin/firefox" does not have this behaviour and works as intended with firefox opening the original link.
Comment 10 Nate Graham 2019-02-01 18:28:17 UTC
Git commit 484a7dc89a757fea830899d9ab9ad36a5f3c99a5 by Nate Graham, on behalf of Mélanie Chauvel.
Committed on 01/02/2019 at 18:27.
Pushed by ngraham into branch 'Plasma/5.15'.

[KRun] Don’t follow redirection to speed up and avoid incorrect behavior

Summary: BUG: 354246

Test Plan:
Launch kde-open5 <URL to a website you have an account and that redirects when not connected>, e.g. <https://twitter.com/i/notifications>.
If it works, we see the correct URL, and not <https://twitter.com/login?redirect_after_login=%2Fi%2Fnotifications>.

Reviewers: #frameworks, dfaure, cfeck

Reviewed By: dfaure

Subscribers: plasma-devel, anthonyfieroni, ngraham, kde-frameworks-devel

Tags: #frameworks, #plasma

Differential Revision: https://phabricator.kde.org/D15189

M  +5    -1    kioclient/kioclient.cpp

https://commits.kde.org/kde-cli-tools/484a7dc89a757fea830899d9ab9ad36a5f3c99a5