1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-28 23:44:32 +00:00

Merge pull request #462 from Gelmir/webui_json

Multiple JSON parses fixes
This commit is contained in:
Christophe Dumez 2013-03-10 11:04:15 -07:00
commit 7234a93293

View File

@ -114,8 +114,11 @@ QVariantMap json::fromJson(const QString& json) {
if (!tmp.isEmpty()) couples << tmp;
foreach (const QString &couple, couples) {
QStringList parts = couple.split(":");
if (parts.size() != 2) continue;
QStringList parts;
int jsonSep = couple.indexOf(":");
parts << couple.left(jsonSep);
parts << couple.mid(jsonSep + 1);
Q_ASSERT(parts.size() == 2);
QString key = parts.first();
if (key.startsWith("\"") && key.endsWith("\"")) {
key = key.mid(1, key.length()-2);
@ -130,7 +133,12 @@ QVariantMap json::fromJson(const QString& json) {
if (list_val.startsWith("\"") && list_val.endsWith("\"")) {
varlist << list_val.mid(1, list_val.length()-2).replace("\\n", "\n");
} 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;