mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-30 03:28:41 -07:00
Separate URL components before percent-decoding
Allow special characters in query string parameters. Closes #9116.
This commit is contained in:
parent
fc534e88a3
commit
b0446380c6
3 changed files with 17 additions and 10 deletions
|
@ -180,11 +180,14 @@ bool RequestParser::parseRequestLine(const QString &line)
|
|||
m_request.method = match.captured(1);
|
||||
|
||||
// Request Target
|
||||
const QByteArray decodedUrl {QByteArray::fromPercentEncoding(match.captured(2).toLatin1())};
|
||||
const int sepPos = decodedUrl.indexOf('?');
|
||||
m_request.path = QString::fromUtf8(decodedUrl.constData(), (sepPos == -1 ? decodedUrl.size() : sepPos));
|
||||
// URL components should be separated before percent-decoding
|
||||
// [rfc3986] 2.4 When to Encode or Decode
|
||||
const QByteArray url {match.captured(2).toLatin1()};
|
||||
const int sepPos = url.indexOf('?');
|
||||
const QByteArray pathComponent = ((sepPos == -1) ? url : Utils::ByteArray::midView(url, 0, sepPos));
|
||||
m_request.path = QString::fromUtf8(QByteArray::fromPercentEncoding(pathComponent));
|
||||
if (sepPos >= 0)
|
||||
m_request.query = decodedUrl.mid(sepPos + 1);
|
||||
m_request.query = url.mid(sepPos + 1);
|
||||
|
||||
// HTTP-version
|
||||
m_request.version = match.captured(3);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue