Index: kio/kio/krun.cpp =================================================================== --- kio/kio/krun.cpp (révision 1074456) +++ kio/kio/krun.cpp (copie de travail) @@ -357,6 +357,30 @@ return 2; } +static QStringList supportedProtocols(const KService& _service, KRunMX1& mx1) +{ + // Check which protocols the application supports. + // This can be a list of actual protocol names, or just KIO for KDE apps. + QStringList supportedProtocols = _service.property("X-KDE-Protocols").toStringList(); + if (!mx1.hasUrls) { + Q_ASSERT(supportedProtocols.isEmpty()); // huh? If you support protocols you need %u or %U... + } else { + if (supportedProtocols.isEmpty()) { + // compat mode: assume KIO if not set and it's a KDE app + const QStringList categories = _service.property("Categories").toStringList(); + if (categories.contains("KDE")) { + supportedProtocols.append("KIO"); + } + else { // if no KDE app, be a bit over-generic + supportedProtocols.append("http"); + supportedProtocols.append("https"); + supportedProtocols.append("ftp"); + } + } + } + return supportedProtocols; +} + QStringList KRun::processDesktopExec(const KService &_service, const KUrl::List& _urls, bool tempFiles, const QString& suggestedFileName) { QString exec = _service.exec(); @@ -393,7 +417,20 @@ } // Check if we need kioexec - if (!mx1.hasUrls) { + bool needKioExec = false; + + const QStringList supportedProtocols = ::supportedProtocols(_service, mx1); + if (!supportedProtocols.contains("KIO")) { + Q_FOREACH(const KUrl& url, _urls) { + const bool supported = url.isLocalFile() || supportedProtocols.contains(url.protocol().toLower()); + if (!supported) { + needKioExec = true; + break; + } + } + } + + if (needKioExec) { for (KUrl::List::ConstIterator it = _urls.begin(); it != _urls.end(); ++it) if (!(*it).isLocalFile() && !KProtocolInfo::isHelperProtocol(*it)) { // We need to run the app through kioexec @@ -675,29 +712,14 @@ // WARNING: don't call this from processDesktopExec, since klauncher uses that too... static KUrl::List resolveURLs(const KUrl::List& _urls, const KService& _service) { - // Check which protocols the application supports. - // This can be a list of actual protocol names, or just KIO for KDE apps. - QStringList supportedProtocols = _service.property("X-KDE-Protocols").toStringList(); KRunMX1 mx1(_service); QString exec = _service.exec(); - if (mx1.expandMacrosShellQuote(exec) && !mx1.hasUrls) { - Q_ASSERT(supportedProtocols.isEmpty()); // huh? If you support protocols you need %u or %U... + if (!mx1.expandMacrosShellQuote(exec)) { // Error in shell syntax + kWarning() << "KRun: syntax error in command" << _service.exec() << ", service" << _service.name(); + return QStringList(); } - else { - if (supportedProtocols.isEmpty()) { - // compat mode: assume KIO if not set and it's a KDE app - QStringList categories = _service.property("Categories").toStringList(); - if (categories.contains("KDE")) { - supportedProtocols.append("KIO"); - } - else { // if no KDE app, be a bit over-generic - supportedProtocols.append("http"); - supportedProtocols.append("ftp"); - } - } - } + const QStringList supportedProtocols = ::supportedProtocols(_service, mx1); kDebug(7010) << "supportedProtocols:" << supportedProtocols; - KUrl::List urls(_urls); if (!supportedProtocols.contains("KIO")) { for (KUrl::List::Iterator it = urls.begin(); it != urls.end(); ++it) {