mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-19 06:57:24 -06:00
Refactor HTTP query parsing
This commit is contained in:
@@ -417,19 +417,8 @@ Http::Response WebApplication::processRequest(const Http::Request &request, cons
|
||||
m_params.clear();
|
||||
|
||||
if (m_request.method == Http::METHOD_GET) {
|
||||
// Parse GET parameters
|
||||
using namespace Utils::ByteArray;
|
||||
for (const QByteArray ¶m : asConst(splitToViews(m_request.query, "&"))) {
|
||||
const int sepPos = param.indexOf('=');
|
||||
if (sepPos <= 0) continue; // ignores params without name
|
||||
|
||||
const QByteArray nameComponent = midView(param, 0, sepPos);
|
||||
const QByteArray valueComponent = midView(param, (sepPos + 1));
|
||||
|
||||
const QString paramName = QString::fromUtf8(QByteArray::fromPercentEncoding(nameComponent).replace('+', ' '));
|
||||
const QString paramValue = QString::fromUtf8(QByteArray::fromPercentEncoding(valueComponent).replace('+', ' '));
|
||||
m_params[paramName] = paramValue;
|
||||
}
|
||||
for (auto iter = m_request.query.cbegin(); iter != m_request.query.cend(); ++iter)
|
||||
m_params[iter.key()] = QString::fromUtf8(iter.value());
|
||||
}
|
||||
else {
|
||||
m_params = m_request.posts;
|
||||
|
||||
Reference in New Issue
Block a user