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.
This commit is contained in:
Chocobo1 2022-08-10 13:19:34 +08:00 committed by GitHub
parent 916e53c260
commit 06c704c740
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -481,15 +481,23 @@ void Application::runExternalProgram(const BitTorrent::Torrent *torrent) const
}); });
proc.startDetached(); proc.startDetached();
#else // Q_OS_WIN #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()) if (args.isEmpty())
return; return;
for (QString &arg : args) 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(); const QString command = args.takeFirst();
QProcess::startDetached(command, args); QProcess::startDetached(command, args);