Summary: | kde-open incorrectly identify url as the http protocol, when the URL includes a plus sign, due to a behavior of QUrl | ||
---|---|---|---|
Product: | [Plasma] kde-cli-tools | Reporter: | ShwStone <haowenshi> |
Component: | general | Assignee: | Aleix Pol <aleixpol> |
Status: | REPORTED --- | ||
Severity: | normal | CC: | haowenshi |
Priority: | NOR | ||
Version First Reported In: | 6.4.5 | ||
Target Milestone: | --- | ||
Platform: | Arch Linux | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: |
Description
ShwStone
2025-10-08 03:55:13 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; >} sorry for messing up the format. the code is also available at https://pastebin.com/rTuaeK02 |