mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-06 13:11:25 -07:00
Fix empty string parameter was omitted
`QProcess::splitCommand()` will omit empty strings like `""` so provide our own replacement. Closes #13124.
This commit is contained in:
parent
2ebdf6060d
commit
0802b6d506
5 changed files with 172 additions and 55 deletions
|
@ -33,6 +33,7 @@
|
|||
|
||||
#include <QLocale>
|
||||
#include <QRegularExpression>
|
||||
#include <QStringList>
|
||||
#include <QVector>
|
||||
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
|
@ -76,6 +77,42 @@ QString Utils::String::wildcardToRegexPattern(const QString &pattern)
|
|||
}
|
||||
#endif
|
||||
|
||||
QStringList Utils::String::splitCommand(const QString &command)
|
||||
{
|
||||
QStringList ret;
|
||||
ret.reserve(32);
|
||||
|
||||
bool inQuotes = false;
|
||||
QString tmp;
|
||||
for (const QChar c : command)
|
||||
{
|
||||
if (c == u' ')
|
||||
{
|
||||
if (!inQuotes)
|
||||
{
|
||||
if (!tmp.isEmpty())
|
||||
{
|
||||
ret.append(tmp);
|
||||
tmp.clear();
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (c == u'"')
|
||||
{
|
||||
inQuotes = !inQuotes;
|
||||
}
|
||||
|
||||
tmp.append(c);
|
||||
}
|
||||
|
||||
if (!tmp.isEmpty())
|
||||
ret.append(tmp);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::optional<bool> Utils::String::parseBool(const QString &string)
|
||||
{
|
||||
if (string.compare(u"true", Qt::CaseInsensitive) == 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue