fix: fix xhttp extra parser

This commit is contained in:
parhelia512 2025-12-04 11:50:10 +08:00 committed by GitHub
parent 5b9022cc38
commit 6d553474df
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -215,11 +215,42 @@ private:
json.contains("downloadSettings"); json.contains("downloadSettings");
} }
static QJsonValue normalizeRangeField(const QJsonValue &val)
{
if (val.isDouble()) {
int num = val.toInt();
QString range = QString("%1-%1").arg(num);
return QJsonValue(range);
} else if (val.isString()) {
int num = val.toString().trimmed().toInt();
if (QString::number(num) == val.toString().trimmed()) {
QString range = QString("%1-%1").arg(num);
return QJsonValue(range);
}
}
return val;
}
static void convertField(const QJsonObject &from, QJsonObject &to, static void convertField(const QJsonObject &from, QJsonObject &to,
const QString &fromKey, const QString &toKey) const QString &fromKey, const QString &toKey)
{ {
if (from.contains(fromKey)) { if (from.contains(fromKey)) {
to[toKey] = from[fromKey]; QJsonValue v = from[fromKey];
if (fromKey == "xPaddingBytes" ||
fromKey == "scMaxEachPostBytes" ||
fromKey == "scMinPostsIntervalMs" ||
fromKey == "scStreamUpServerSecs" ||
fromKey == "maxConcurrency" ||
fromKey == "maxConnections" ||
fromKey == "cMaxReuseTimes" ||
fromKey == "hMaxRequestTimes" ||
fromKey == "hMaxReusableSecs") {
v = normalizeRangeField(v);
}
to[toKey] = v;
} }
} }