1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-22 20:44:15 +00:00

Merge pull request #3515 from glassez/parser

Fix HTTP header parsing. Closes #3511.
This commit is contained in:
sledgehammer999 2015-07-31 02:38:04 +03:00
commit a217988dbb

View File

@ -330,16 +330,22 @@ bool RequestParser::parseFormData(const QByteArray& data)
bool RequestParser::parseHeaderValue(const QString& value, QStringMap& out) bool RequestParser::parseHeaderValue(const QString& value, QStringMap& out)
{ {
QStringList items = value.split(QLatin1Char(';')); int pos = value.indexOf(QLatin1Char(';'));
out[""] = items[0]; if (pos == -1) {
out[""] = value.trimmed();
for (QStringList::size_type i = 1; i < items.size(); ++i) { return true;
int pos = items[i].indexOf("=");
if (pos < 0)
return false;
out[items[i].left(pos).trimmed()] = unquoted(items[i].mid(pos + 1).trimmed());
} }
out[""] = value.left(pos).trimmed();
QRegExp rx(";\\s*([^=;\"]+)\\s*=\\s*(\"[^\"]*\"|[^\";\\s]+)\\s*");
while (rx.indexIn(value, pos) == pos) {
out[rx.cap(1).trimmed()] = unquoted(rx.cap(2));
pos += rx.cap(0).length();
}
if (pos != value.length())
return false;
return true; return true;
} }