mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-30 00:14:57 +00:00
Merge pull request #462 from Gelmir/webui_json
Multiple JSON parses fixes
This commit is contained in:
commit
7234a93293
@ -114,8 +114,11 @@ QVariantMap json::fromJson(const QString& json) {
|
|||||||
if (!tmp.isEmpty()) couples << tmp;
|
if (!tmp.isEmpty()) couples << tmp;
|
||||||
|
|
||||||
foreach (const QString &couple, couples) {
|
foreach (const QString &couple, couples) {
|
||||||
QStringList parts = couple.split(":");
|
QStringList parts;
|
||||||
if (parts.size() != 2) continue;
|
int jsonSep = couple.indexOf(":");
|
||||||
|
parts << couple.left(jsonSep);
|
||||||
|
parts << couple.mid(jsonSep + 1);
|
||||||
|
Q_ASSERT(parts.size() == 2);
|
||||||
QString key = parts.first();
|
QString key = parts.first();
|
||||||
if (key.startsWith("\"") && key.endsWith("\"")) {
|
if (key.startsWith("\"") && key.endsWith("\"")) {
|
||||||
key = key.mid(1, key.length()-2);
|
key = key.mid(1, key.length()-2);
|
||||||
@ -130,7 +133,12 @@ QVariantMap json::fromJson(const QString& json) {
|
|||||||
if (list_val.startsWith("\"") && list_val.endsWith("\"")) {
|
if (list_val.startsWith("\"") && list_val.endsWith("\"")) {
|
||||||
varlist << list_val.mid(1, list_val.length()-2).replace("\\n", "\n");
|
varlist << list_val.mid(1, list_val.length()-2).replace("\\n", "\n");
|
||||||
} else {
|
} else {
|
||||||
varlist << list_val.toInt();
|
if (list_val.compare("false", Qt::CaseInsensitive) == 0)
|
||||||
|
varlist << false;
|
||||||
|
else if (list_val.compare("true", Qt::CaseInsensitive) == 0)
|
||||||
|
varlist << true;
|
||||||
|
else
|
||||||
|
varlist << list_val.toInt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
value = varlist;
|
value = varlist;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user