Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.10/site-packages/django/http/cookie.py: 25%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1from http import cookies
3# For backwards compatibility in Django 2.1.
4SimpleCookie = cookies.SimpleCookie
7def parse_cookie(cookie):
8 """
9 Return a dictionary parsed from a `Cookie:` header string.
10 """
11 cookiedict = {}
12 for chunk in cookie.split(";"):
13 if "=" in chunk:
14 key, val = chunk.split("=", 1)
15 else:
16 # Assume an empty name per
17 # https://bugzilla.mozilla.org/show_bug.cgi?id=169091
18 key, val = "", chunk
19 key, val = key.strip(), val.strip()
20 if key or val:
21 # unquote using Python's algorithm.
22 cookiedict[key] = cookies._unquote(val)
23 return cookiedict