From 612b8debbc8f7e916283a0109afbc7c6b6b60345 Mon Sep 17 00:00:00 2001 From: dongshengyuan <545258830@qq.com> Date: Tue, 30 Jun 2026 21:20:14 +0800 Subject: [PATCH] fix(dbus): preserve custom URI schemes in %U/%u Exec field expansion QUrl::fromUserInput() treats unrecognized schemes as HTTP hostnames, rewriting e.g. 'ksowpscloudsvr://start=RelayHttpServer' into 'http://ksowpscloudsvr//start=RelayHttpServer', which silently breaks any application registered as a custom protocol handler via x-scheme-handler MIME type (e.g. WPS Office OA integration). Root cause: commit 9dd7e7f ('fix: dde-open file failed') replaced QUrl{field} with QUrl::fromUserInput(field) to fix local file path handling (toLocalFile() returning empty for bare paths). However, fromUserInput's smart-guessing logic corrupts custom URI schemes by treating the scheme name as an HTTP hostname. Fix: detect fields that already carry a scheme ('://') and parse them directly with QUrl::TolerantMode, which accepts non-RFC-compliant host components such as 'start=RelayHttpServer'. Bare file paths (no '://') continue to use fromUserInput as before, preserving the original fix. Regressed-by: 9dd7e7f2a11e311f88cb4840cfb6e11524fe80fb --- src/dbus/applicationservice.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/dbus/applicationservice.cpp b/src/dbus/applicationservice.cpp index 4626f45e..01563db9 100644 --- a/src/dbus/applicationservice.cpp +++ b/src/dbus/applicationservice.cpp @@ -1476,7 +1476,19 @@ LaunchTask ApplicationService::processExec(const QString &str, const QStringList QList resources; resources.reserve(fields.size()); for (const auto &field : fields) { - resources.emplace_back(QUrl::fromUserInput(field, dir, QUrl::AssumeLocalFile)); + // Fix: preserve custom URI schemes (e.g. ksowpscloudsvr://) + // QUrl::fromUserInput() treats unknown schemes as HTTP hostnames, + // rewriting "ksowpscloudsvr://x" -> "http://ksowpscloudsvr//x". + // If the field already contains "://", parse it with TolerantMode + // (which accepts non-RFC-compliant host parts like "start=foo") + // and skip fromUserInput entirely. + QUrl url; + if (field.contains(u"://"_s)) { + url = QUrl(field, QUrl::TolerantMode); + } else { + url = QUrl::fromUserInput(field, dir, QUrl::AssumeLocalFile); + } + resources.emplace_back(std::move(url)); } if (code.isUpper()) {