mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-31 04:38:04 -06: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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user