Browse Source

Merge pull request #3515 from glassez/parser

Fix HTTP header parsing. Closes #3511.
adaptive-webui-19844
sledgehammer999 9 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)
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();
return true;
}
for (QStringList::size_type i = 1; i < items.size(); ++i) { out[""] = value.left(pos).trimmed();
int pos = items[i].indexOf("=");
if (pos < 0)
return false;
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; return true;
} }

Loading…
Cancel
Save