From 06c704c74063d264d98a5fbe72d2578efd4e6a75 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 10 Aug 2022 13:19:34 +0800 Subject: [PATCH] Revise quote behavior Now the behavior of double quotes aligns more as with issuing commands from shell/command line. Related: https://github.com/qbittorrent/qBittorrent/pull/17453#issuecomment-1203372027 PR #17515. --- src/app/application.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/app/application.cpp b/src/app/application.cpp index 67cdd58f3..acd650f5a 100644 --- a/src/app/application.cpp +++ b/src/app/application.cpp @@ -481,15 +481,23 @@ void Application::runExternalProgram(const BitTorrent::Torrent *torrent) const }); proc.startDetached(); #else // Q_OS_WIN - QStringList args = Utils::String::splitCommand(Preferences::instance()->getAutoRunProgram().trimmed()); + const QString program = Preferences::instance()->getAutoRunProgram().trimmed(); + QStringList args = Utils::String::splitCommand(program); if (args.isEmpty()) return; for (QString &arg : args) - arg = replaceVariables(arg); + { + // strip redundant quotes + if (arg.startsWith(u'"') && arg.endsWith(u'"')) + arg = arg.mid(1, (arg.size() - 2)); - LogMsg(logMsg.arg(torrent->name(), args.join(u' '))); + arg = replaceVariables(arg); + } + + // show intended command in log + LogMsg(logMsg.arg(torrent->name(), replaceVariables(program))); const QString command = args.takeFirst(); QProcess::startDetached(command, args);