Bug 401013 - kde-open/xdg-open does not handle symbols at start or end of schema URL
Summary: kde-open/xdg-open does not handle symbols at start or end of schema URL
Status: RESOLVED NOT A BUG
Alias: None
Product: kde-cli-tools
Classification: Plasma
Component: general (show other bugs)
Version: 5.16.90
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Aleix Pol
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-11-13 19:01 UTC by Matt O
Modified: 2019-12-02 22:36 UTC (History)
5 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matt O 2018-11-13 19:01:50 UTC
SUMMARY
This relates to URI handlers, and how they are processed via xdg-open/kde-open.  If the URI contains symbols at the front or end, then the protocol portion of the URI will be treated as a hostname, and an error will be returned:

kf5.kio.widgets: KRun(0x1234567890) ERROR (stat): 114   "Unknown host protocol: Host not found"


STEPS TO REPRODUCE
1. Execute in a console: xdg-open test://example--

OBSERVED RESULT
Error message is returned:
kf5.kio.widgets: KRun(0x001234567890) ERROR (stat): 114   "Unknown host test: Host not found"


EXPECTED RESULT
Message returned:
kf5.kio.core: Refilling KProtocolInfoFactory cache in the hope to find "test"

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Kubuntu 18.04
(available in About System)
KDE Plasma Version: 5.12.6
KDE Frameworks Version: 5.44.0
Qt Version: 5.9.5

ADDITIONAL INFORMATION
I'm not entirely clear where this bug lies, as I'm not fully understanding the structure of the framework that is involved.  Please let me know if I've filed this in the wrong place.

You can see the correct behavior by executing the same command without the -- on the end:
xdg-open test://example

You can test this with any protocol handler, so long as the part after :// is either preceded with or followed by a symbol.

The specific piece of software I am having issue with is SolarWinds N-Central MSP connect agent(via WINE).  It produces a long unique string followed by -- as the URI.  Ex:
mspancsxvp://thisisjustanexampleofareallylongstringofcharactersthatrepresentswhatmspconnectmightuseforaguid--
Comment 1 Rex Dieter 2018-11-13 21:01:37 UTC
Can you test with kde5-open only instead?  that will help
Comment 2 Matt O 2018-11-14 01:50:37 UTC
Thanks for the response.

I believe you mean kde-open5 (let me know if you are referring to something else)

Here are the results of several tests:

kde-open5 --version
kioclient 5.12.6

kde-open5 test://example--
kf5.kio.widgets: KRun(0x5651178bdc60) ERROR (stat): 114   "Unknown host test: Host not found"


kde-open --version
Qt: 4.8.7
KDE Development Platform: 4.14.38
KIO Client: 2.0

kde-open test://example--
Malformed URL
test:


xdg-open --version
xdg-open 1.1.2

xdg-open test://example--
kf5.kio.widgets: KRun(0x55b0ec356a10) ERROR (stat): 114   "Unknown host test: Host not found"


/usr/lib/node_modules/angular-cli/node_modules/opn/xdg-open --version
xdg-open 1.1.0 rc3

/usr/lib/node_modules/angular-cli/node_modules/opn/xdg-open test://example--
kf5.kio.widgets: KRun(0x55991c81cb30) ERROR (stat): 114   "Unknown host test: Host not found"

----------
In all of these cases, the error message is returned from KIO, either via the terminal, an alert window, or both.

In all cases, if I use "test://example" instead of "test://example--", a different and proper error message is returned.  The correct error message indicates that there is no handler registered for "test".  The incorrect message always gives an error that indicates that "test" is being interpreted as a hostname, as opposed to a protocol.
Comment 3 Ahmad Samir 2019-09-24 20:20:12 UTC
Looks like it's a bug in ClientApp::kde_open() [1]:
for "test://example" info.url is QUrl("test://example")
for "test://example--" info.url is QUrl("http://test//example--")

[1] https://cgit.kde.org/kde-cli-tools.git/tree/kioclient/kioclient.cpp#n212
Comment 4 David Faure 2019-12-02 22:36:25 UTC
I think that's because the "--" is invalid hostname. That's QUrl's behaviour itself, i.e. it comes from Qt.

This has to do with the IDNA "standard", see http://www.rfc-editor.org/rfc/rfc3490.txt

I don't believe this is a kde-open bug in any form.
You can try playing with QUrl and filing a Qt bug, but I think the answer will be that your URL is not IDNA-conform. So better find a different solution than the "--" thing.