diff --git a/src/core/desktopexecparser.cpp b/src/core/desktopexecparser.cpp --- a/src/core/desktopexecparser.cpp +++ b/src/core/desktopexecparser.cpp @@ -208,6 +208,14 @@ } } } + + // add x-scheme-handler/ + for (const auto &mimeType : service.mimeTypes()) { + if (mimeType.startsWith(QStringLiteral("x-scheme-handler/"))) { + supportedProtocols << mimeType.mid(17); + } + } + //qCDebug(KIO_CORE) << "supportedProtocols:" << supportedProtocols; return supportedProtocols; } @@ -334,7 +342,7 @@ // Hence convert URL to KIOFuse equivalent in case there is a password. // @see https://pointieststick.com/2018/01/17/videos-on-samba-shares/ // @see https://bugs.kde.org/show_bug.cgi?id=330192 - if (!supported || (!url.userName().isEmpty() && url.password().isEmpty())) { + if ((!supported || (!url.userName().isEmpty() && url.password().isEmpty())) && !(url.scheme() == QStringLiteral("mailto"))) { requests.push_back({ kiofuse_iface.mountUrl(url.toString()), i }); } } diff --git a/src/widgets/krun.cpp b/src/widgets/krun.cpp --- a/src/widgets/krun.cpp +++ b/src/widgets/krun.cpp @@ -96,25 +96,14 @@ // --------------------------------------------------------------------------- -static QString schemeHandler(const QString &protocol) -{ - // We have up to two sources of data, for protocols not handled by kioslaves (so called "helper") : - // 1) the exec line of the .protocol file, if there's one - // 2) the application associated with x-scheme-handler/ if there's one - - // If both exist, then: - // A) if the .protocol file says "launch an application", then the new-style handler-app has priority - // B) but if the .protocol file is for a kioslave (e.g. kio_http) then this has priority over - // firefox or chromium saying x-scheme-handler/http. Gnome people want to send all HTTP urls - // to a webbrowser, but we want mimetype-determination-in-calling-application by default - // (the user can configure a BrowserApplication though) +static KService::Ptr schemeService(const QString &protocol) +{ const KService::Ptr service = KMimeTypeTrader::self()->preferredService(QLatin1String("x-scheme-handler/") + protocol); if (service) { - return service->exec(); // for helper protocols, the handler app has priority over the hardcoded one (see A above) + return service; } - Q_ASSERT(KProtocolInfo::isHelperProtocol(protocol)); - return KProtocolInfo::exec(protocol); + return KService::Ptr(); } static bool checkNeedPortalSupport() @@ -960,18 +949,33 @@ return; } } else if (KIO::DesktopExecParser::hasSchemeHandler(d->m_strURL)) { - //qDebug() << "Using scheme handler"; - const QString exec = schemeHandler(d->m_strURL.scheme()); - if (exec.isEmpty()) { - mimeTypeDetermined(KProtocolManager::defaultMimetype(d->m_strURL)); - return; - } else { - if (run(exec, QList() << d->m_strURL, d->m_window, QString(), QString(), d->m_asn)) { + // looks for an application associated with x-scheme-handler/ + const KService::Ptr service = schemeService(d->m_strURL.scheme()); + if (service) { + // if there's one... + if (runApplication(*service, QList() << d->m_strURL, d->m_window)) { d->m_bFinished = true; d->startTimer(); return; } + } else { + // fallback, look for associated helper protocol + Q_ASSERT(KProtocolInfo::isHelperProtocol(d->m_strURL.scheme())); + const auto exec = KProtocolInfo::exec(d->m_strURL.scheme()); + if (exec.isEmpty()) { + // the scheme has no service or protocol associated + // use url scheme associated protocol + mimeTypeDetermined(KProtocolManager::defaultMimetype(d->m_strURL)); + return; + } else { + if ( run(exec, QList() << d->m_strURL, d->m_window, QString(), QString(), d->m_asn)) { + d->m_bFinished = true; + d->startTimer(); + return; + } + } } + } #if 0 // removed for KF5 (for portability). Reintroduce a bool or flag if useful.