diff options
author | Peter Hartmann <peter.hartmann@nokia.com> | 2011-04-27 11:48:53 +0200 |
---|---|---|
committer | Peter Hartmann <peter.hartmann@nokia.com> | 2011-05-04 14:20:46 +0200 |
commit | 863de43dcad501a6c9675823217d0abf0269f802 (patch) | |
tree | 6f516fc6ee3e8c008e3de245174d291e946f6adc /src/network | |
parent | 8e9aa019bb2183d0a8f56c3fdbaf829f0a4efff6 (diff) |
QNetworkCookie: allow spaces in unquoted values
We should follow
http://tools.ietf.org/html/draft-ietf-httpstate-cookie-23 , which says
parse the value until reaching the next ';' or the end of the line.
Other cookie implementations allow spaces in unquoted values as well.
Reviewed-by: Martin Petersson
Task-number: QTBUG-18876
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/access/qnetworkcookie.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/network/access/qnetworkcookie.cpp b/src/network/access/qnetworkcookie.cpp index 52eb3453b8..eec850797b 100644 --- a/src/network/access/qnetworkcookie.cpp +++ b/src/network/access/qnetworkcookie.cpp @@ -395,8 +395,8 @@ static QPair<QByteArray, QByteArray> nextField(const QByteArray &text, int &posi // qdtext = <any TEXT except <">> // quoted-pair = "\" CHAR - // If its NAME=VALUE, retain the value as is - // refer to ttp://bugreports.qt.nokia.com/browse/QTBUG-17746 + // If it is NAME=VALUE, retain the value as is + // refer to http://bugreports.qt.nokia.com/browse/QTBUG-17746 if (isNameValue) second += '"'; ++i; @@ -432,7 +432,9 @@ static QPair<QByteArray, QByteArray> nextField(const QByteArray &text, int &posi position = i; for ( ; i < length; ++i) { register char c = text.at(i); - if (c == ',' || c == ';' || isLWS(c)) + // for name value pairs, we want to parse until reaching the next ';' + // and not break when reaching a space char + if (c == ',' || c == ';' || ((isNameValue && (c == '\n' || c == '\r')) || (!isNameValue && isLWS(c)))) break; } @@ -487,7 +489,6 @@ QByteArray QNetworkCookie::toRawForm(RawForm form) const result += '='; if ((d->value.contains(';') || d->value.contains(',') || - d->value.contains(' ') || d->value.contains('"')) && (!d->value.startsWith('"') && !d->value.endsWith('"'))) { |