HTTP: fixed cookie parsing.
The fixing supports the cookie value with the '=' character. This is related to #756 PR on Github. Thanks to changxiaocui.
This commit is contained in:
@@ -31,6 +31,12 @@ NGINX Unit updated to 1.29.0.
|
|||||||
date="" time=""
|
date="" time=""
|
||||||
packager="Nginx Packaging <nginx-packaging@f5.com>">
|
packager="Nginx Packaging <nginx-packaging@f5.com>">
|
||||||
|
|
||||||
|
<change type="bugfix">
|
||||||
|
<para>
|
||||||
|
fix HTTP cookie parsing when the value contains an equals sign.
|
||||||
|
</para>
|
||||||
|
</change>
|
||||||
|
|
||||||
</changes>
|
</changes>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1035,14 +1035,11 @@ nxt_http_cookie_parse(nxt_array_t *cookies, u_char *start, const u_char *end)
|
|||||||
for (p = start; p < end; p++) {
|
for (p = start; p < end; p++) {
|
||||||
c = *p;
|
c = *p;
|
||||||
|
|
||||||
if (c == '=') {
|
if (c == '=' && name == NULL) {
|
||||||
while (start[0] == ' ') { start++; }
|
while (start[0] == ' ') { start++; }
|
||||||
|
|
||||||
name_length = p - start;
|
name_length = p - start;
|
||||||
|
|
||||||
if (name_length != 0) {
|
|
||||||
name = start;
|
name = start;
|
||||||
}
|
|
||||||
|
|
||||||
start = p + 1;
|
start = p + 1;
|
||||||
|
|
||||||
|
|||||||
@@ -1401,6 +1401,20 @@ class TestRouting(TestApplicationPython):
|
|||||||
self.route_match_invalid({"cookies": ["var"]})
|
self.route_match_invalid({"cookies": ["var"]})
|
||||||
self.route_match_invalid({"cookies": [{"foo": {}}]})
|
self.route_match_invalid({"cookies": [{"foo": {}}]})
|
||||||
|
|
||||||
|
def test_routes_match_cookies_complex(self):
|
||||||
|
self.route_match({"cookies": {"foo": "bar=baz"}})
|
||||||
|
self.cookie('foo=bar=baz', 200)
|
||||||
|
self.cookie(' foo=bar=baz ', 200)
|
||||||
|
self.cookie('=foo=bar=baz', 404)
|
||||||
|
|
||||||
|
self.route_match({"cookies": {"foo": ""}})
|
||||||
|
self.cookie('foo=', 200)
|
||||||
|
self.cookie('foo=;', 200)
|
||||||
|
self.cookie(' foo=;', 200)
|
||||||
|
self.cookie('foo', 404)
|
||||||
|
self.cookie('', 404)
|
||||||
|
self.cookie('=', 404)
|
||||||
|
|
||||||
def test_routes_match_cookies_multiple(self):
|
def test_routes_match_cookies_multiple(self):
|
||||||
self.route_match({"cookies": {"foo": "bar", "blah": "blah"}})
|
self.route_match({"cookies": {"foo": "bar", "blah": "blah"}})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user