Browse Source

Merge pull request #3515 from glassez/parser

Fix HTTP header parsing. Closes #3511.
adaptive-webui-19844
sledgehammer999 10 years ago
parent
commit
a217988dbb
  1. 20
      src/core/http/requestparser.cpp

20
src/core/http/requestparser.cpp

@ -330,16 +330,22 @@ bool RequestParser::parseFormData(const QByteArray& data) @@ -330,16 +330,22 @@ bool RequestParser::parseFormData(const QByteArray& data)
bool RequestParser::parseHeaderValue(const QString& value, QStringMap& out)
{
QStringList items = value.split(QLatin1Char(';'));
out[""] = items[0];
int pos = value.indexOf(QLatin1Char(';'));
if (pos == -1) {
out[""] = value.trimmed();
return true;
}
for (QStringList::size_type i = 1; i < items.size(); ++i) {
int pos = items[i].indexOf("=");
if (pos < 0)
return false;
out[""] = value.left(pos).trimmed();
out[items[i].left(pos).trimmed()] = unquoted(items[i].mid(pos + 1).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;
}

Loading…
Cancel
Save