Bug 510371 - kde-open incorrectly identify url as the http protocol, when the URL includes a plus sign, due to a behavior of QUrl
Summary: kde-open incorrectly identify url as the http protocol, when the URL includes...
Status: REPORTED
Alias: None
Product: kde-cli-tools
Classification: Plasma
Component: general (other bugs)
Version First Reported In: 6.4.5
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Aleix Pol
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-10-08 03:55 UTC by ShwStone
Modified: 2025-10-08 04:07 UTC (History)
1 user (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 ShwStone 2025-10-08 03:55:13 UTC
***
If you're not sure this is actually a bug, instead post about it at https://discuss.kde.org

If you're reporting a crash, attach a backtrace with debug symbols; see https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports

Please remove this comment after reading and before submitting - thanks!
***

SUMMARY


STEPS TO REPRODUCE
1. install vscode
2. open a file on remote ssh server. for example, in vscode terminal, try code my.file. 
3. or just try kde-open "vscode://abc+de"

OBSERVED RESULT
browser is opened

EXPECTED RESULT
vscode shoule be opened

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
(available in the Info Center app, or by running `kinfo` in a terminal window)
Linux/KDE Plasma: ArchLinux
KDE Plasma Version: 6.4.5
KDE Frameworks Version: 6.18.0
Qt Version: 6.9.2

ADDITIONAL INFORMATION
kde-open5 also have this problem
Comment 1 ShwStone 2025-10-08 04:04:20 UTC
I am sure this is caused by a behavior of QUrl::fromUserInput

When opening a remote file via the `vscode-remote` protocol, `xdg-open` receives a URL similar to this:
`vscode-remote://ssh+devserver/my/file/path`
(Where `ssh+` is an integral part of the scheme identifier.)

As I know, kde-open uses QUrl::fromUserInput to convert the input string into a QUrl object. It then uses the resulting scheme to look up a registered x-scheme-handler and select the appropriate application.

When the input string's scheme contains a plus sign (+), QUrl::fromUserInput automatically prepends "http://" to the link. This forces the URL to be interpreted under the `http` protocol, which prevents `kde-open` from finding the correct program and ultimately causes a browser to be launched.

My analysis of the documentation and source code suggests that URLs containing a `+` sign (or its escape, `%2B`) are considered "invalid" by Qt's initial parsing logic, triggering `QUrl::fromUserInput`'s "best guess" mechanism, incorrectly defaults to prepending `http://`.

I've tried ask in QT forum, one of QT developer thinks this is not a QT problem. But it is clear that either KDE or QT should make a change.(since this is a basic function and gio open handles it perfectly).

If a change cannot be made at the Qt level, should KDE reconsider using `QUrl::fromUserInput` for accepting general URL input in utilities like `kde-open`?

I am not affiliated with the KDE or Qt development teams, but I am keen to contribute to the resolution of this bug. I'm seeking insight into the underlying standards and the most appropriate path forward.

BTW, following code can easily verify the core problem:

> #include <QString>
> #include <QUrl>
> #include <QDebug>
> int main() {
>    auto url = QUrl::fromUserInput("vscode-remote://ssh+devserver"); 
>    qDebug() << url; // QUrl("http://vscode-remote//ssh+devserver")
>
>    url.setUrl("vscode-remote://ssh+devserver");
>    qDebug() << url.isValid(); // false
>
>    url.setUrl("vscode-remote://sshdevserver");
>    qDebug() << url.isValid(); // true
>
>    url.setUrl("vscode-remote://ssh%2Bdevserver");
>    qDebug() << url.isValid(); // false
>    return 0;
>}
Comment 2 ShwStone 2025-10-08 04:05:50 UTC
sorry for messing up the format. the code is also available at https://pastebin.com/rTuaeK02