From 6d553474df6ec87ee11035c3697c5ba27a63c739 Mon Sep 17 00:00:00 2001 From: parhelia512 <0011d3@gmail.com> Date: Thu, 4 Dec 2025 11:50:10 +0800 Subject: [PATCH] fix: fix xhttp extra parser --- include/global/XhttpExtraConverter.hpp | 33 +++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/include/global/XhttpExtraConverter.hpp b/include/global/XhttpExtraConverter.hpp index 7e1f6fb..35f38d2 100644 --- a/include/global/XhttpExtraConverter.hpp +++ b/include/global/XhttpExtraConverter.hpp @@ -215,11 +215,42 @@ private: 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, const QString &fromKey, const QString &toKey) { 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; } }