From 25d81b76b9639b8fd27848b37ca79ef979a945fc Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Sun, 12 May 2024 14:40:26 +0300 Subject: [PATCH] kio: slightly better exec extraction in KOpenWithDialog the matching could try basename and possibly second argument match tho, e.g. the Exec key value could be relative or full path and interpreter may be the first argument with the actual program (or script rather) second making the matching kinda hard to get right Signed-off-by: Ivailo Monev --- kio/kfile/kopenwithdialog.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/kio/kfile/kopenwithdialog.cpp b/kio/kfile/kopenwithdialog.cpp index f1c5c09f..5623f4c4 100644 --- a/kio/kfile/kopenwithdialog.cpp +++ b/kio/kfile/kopenwithdialog.cpp @@ -55,14 +55,11 @@ static QString simplifiedExecLineFromService(const QString& fullExec) { - QString exec = fullExec; - exec.remove("%u", Qt::CaseInsensitive); - exec.remove("%f", Qt::CaseInsensitive); - exec.remove("-caption %c"); - exec.remove("-caption \"%c\""); - exec.remove("%i"); - exec.remove("%m"); - return exec.simplified(); + QStringList args = KShell::splitArgs(fullExec); + if (args.isEmpty()) { + return QString(); + } + return args.first().simplified(); } namespace KDEPrivate {