mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-17 14:08:03 -06:00
Allow equals character in the command line value
The CLI options should allow the `=` (equals) char as value so doing `--save-path="/home/test/mydir = somedir"` should parse properly with the `value` method returning `"/home/test/mydir = somedir"`. Closes #23248. PR #23251. --------- Co-authored-by: Vladimir Golovnev <glassez@yandex.ru> Co-authored-by: Chocobo1 <Chocobo1@users.noreply.github.com>
This commit is contained in:
committed by
Vladimir Golovnev (glassez)
parent
772ba5f6bc
commit
015950ea61
@@ -147,12 +147,14 @@ namespace
|
|||||||
|
|
||||||
QString value(const QString &arg) const
|
QString value(const QString &arg) const
|
||||||
{
|
{
|
||||||
QStringList parts = arg.split(u'=');
|
const qsizetype index = arg.indexOf(u'=');
|
||||||
if (parts.size() == 2)
|
if (index == -1)
|
||||||
return Utils::String::unquote(parts[1], u"'\""_s);
|
throw CommandLineParameterError(QCoreApplication::translate("CMD Options", "Parameter '%1' must follow syntax '%1=%2'",
|
||||||
throw CommandLineParameterError(QCoreApplication::translate("CMD Options", "Parameter '%1' must follow syntax '%1=%2'",
|
|
||||||
"e.g. Parameter '--webui-port' must follow syntax '--webui-port=value'")
|
"e.g. Parameter '--webui-port' must follow syntax '--webui-port=value'")
|
||||||
.arg(fullParameter(), u"<value>"_s));
|
.arg(fullParameter(), u"<value>"_s));
|
||||||
|
|
||||||
|
const QStringView val = QStringView(arg).sliced(index + 1);
|
||||||
|
return Utils::String::unquote(val, u"'\""_s).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString value(const QProcessEnvironment &env, const QString &defaultValue = {}) const
|
QString value(const QProcessEnvironment &env, const QString &defaultValue = {}) const
|
||||||
@@ -168,7 +170,7 @@ namespace
|
|||||||
|
|
||||||
friend bool operator==(const StringOption &option, const QString &arg)
|
friend bool operator==(const StringOption &option, const QString &arg)
|
||||||
{
|
{
|
||||||
return arg.startsWith(option.parameterAssignment());
|
return (arg == option.fullParameter()) || arg.startsWith(option.parameterAssignment());
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user