diff --git a/autotests/krununittest.h b/autotests/krununittest.h --- a/autotests/krununittest.h +++ b/autotests/krununittest.h @@ -35,6 +35,7 @@ void testProcessDesktopExec(); void testProcessDesktopExecNoFile_data(); void testProcessDesktopExecNoFile(); + void testKtelnetservice(); void testMimeTypeFile(); void testMimeTypeDirectory(); diff --git a/autotests/krununittest.cpp b/autotests/krununittest.cpp --- a/autotests/krununittest.cpp +++ b/autotests/krununittest.cpp @@ -233,6 +233,31 @@ QCOMPARE(KShell::joinArgs(parser.resultingArguments()), expected); } +void KRunUnitTest::testKtelnetservice() +{ + const QString ktelnetDesk = QFINDTESTDATA(QStringLiteral("../src/ioslaves/telnet/ktelnetservice5.desktop")); + QVERIFY(!ktelnetDesk.isEmpty()); + + QString ktelnetExec = QStandardPaths::findExecutable(QStringLiteral("ktelnetservice5")); + + const KService service(ktelnetDesk); + + // if KIO is installed we'll find /ktelnetservice5, otherwise KIO::DesktopExecParser will + // use the executable from Exec= line + if (ktelnetExec.isEmpty()) { + ktelnetExec = service.exec().remove(QLatin1String(" %u")); + } + QVERIFY(!ktelnetExec.isEmpty()); + + const QStringList protocols({QStringLiteral("ssh"), QStringLiteral("telnet"), QStringLiteral("rlogin")}); + for (const QString &protocol : protocols) { + QList urls({QUrl(QStringLiteral("%1://root@10.1.1.1").arg(protocol))}); + KIO::DesktopExecParser parser(service, urls); + QCOMPARE(KShell::joinArgs(parser.resultingArguments()), + QStringLiteral("%1 %2://root@10.1.1.1").arg(ktelnetExec, protocol)); + } +} + class KRunImpl : public KRun { public: diff --git a/src/core/desktopexecparser.cpp b/src/core/desktopexecparser.cpp --- a/src/core/desktopexecparser.cpp +++ b/src/core/desktopexecparser.cpp @@ -347,6 +347,9 @@ } else if (!appSupportedProtocols.contains(QLatin1String("KIO"))) { for (int i = 0; i < d->urls.count(); ++i) { const QUrl url = d->urls.at(i); + if (hasSchemeHandler(url)) { + break; + } const bool supported = isProtocolInSupportedList(url, appSupportedProtocols); // NOTE: Some non-KIO apps may support the URLs (e.g. VLC supports smb://) // but will not have the password if they are not in the URL itself.