From 9685acf1bbc6ba1f591b37b8be4250a604fcc0bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9ven=20Car?= Date: Thu, 15 Oct 2026 08:37:54 +0000 Subject: [PATCH] dolphinmainwindow: pass the folder of the custom command as one argument Before this change, {path} was replaced with the folder path in double quotes. A folder name with a double quote or a dollar sign then gave the command a different path. {path} is now replaced with the path quoted by KShell::quoteArg. A {path} that the command already has in quotes gets the same path. --- src/dolphinmainwindow.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index ab48a528c8..49c68d3c6b 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -3258,9 +3258,11 @@ void DolphinMainWindow::slotDoubleClickViewBackground(Qt::MouseButton button) if (clickAction == customCommand) { // run custom command set by the user - QString path = view->url().toLocalFile(); QString clickCustomAction = settings->doubleClickViewCustomAction(); - clickCustomAction.replace("{path}", path.prepend('"').append('"')); + // {path} becomes one quoted shell word, also when the command already has it in quotes. + clickCustomAction.replace(QLatin1String("\"{path}\""), QLatin1String("{path}")); + clickCustomAction.replace(QLatin1String("'{path}'"), QLatin1String("{path}")); + clickCustomAction.replace(QLatin1String("{path}"), KShell::quoteArg(view->url().toLocalFile())); m_job = new KIO::CommandLauncherJob(clickCustomAction); m_job->setUiDelegate(new KDialogJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this)); -- GitLab