# HG changeset patch # User Pathangi Jatinshravan # Date 1444222247 -28800 # Wed Oct 07 20:50:47 2015 +0800 # Node ID bfca0e5f207cfcef3d70f7946eb9b48f89bf9776 # Parent 3291e6132a674606af028be2d500701e5ff8285a Fixes issue where one invalid cookie caused the rest of the cookies to be ignored, along with unit test coverage diff --git a/Lib/http/cookies.py b/Lib/http/cookies.py --- a/Lib/http/cookies.py +++ b/Lib/http/cookies.py @@ -576,8 +576,14 @@ # Start looking for a cookie match = patt.match(str, i) if not match: - # No more cookies - break + if ';' not in str: + break + else: + while not str[i] == ';': + i += 1 + + i += 1 + continue key, value = match.group("key"), match.group("val") i = match.end(0) diff --git a/Lib/test/test_http_cookies.py b/Lib/test/test_http_cookies.py --- a/Lib/test/test_http_cookies.py +++ b/Lib/test/test_http_cookies.py @@ -56,7 +56,16 @@ 'Set-Cookie: d=r', 'Set-Cookie: f=h' )) - } + }, + { + 'data': 'a=b; messages=[\"\"]; c=d;', + 'dict': {'a':'b', 'c':'d'}, + 'repr': "", + 'output': '\n'.join(( + 'Set-Cookie: a=b', + 'Set-Cookie: c=d', + )) + }, ] for case in cases: