Coverage for /var/srv/projects/api.amasfac.comuna18.com/tmp/venv/lib/python3.9/site-packages/django/http/cookie.py: 78%

12 statements  

« prev     ^ index     » next       coverage.py v6.4.4, created at 2023-07-17 14:22 -0600

1from http import cookies 

2 

3# For backwards compatibility in Django 2.1. 

4SimpleCookie = cookies.SimpleCookie 

5 

6 

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: 13 ↛ 14line 13 didn't jump to line 14, because the condition on line 13 was never true

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: 20 ↛ 22line 20 didn't jump to line 22, because the condition on line 20 was never true

21 # unquote using Python's algorithm. 

22 cookiedict[key] = cookies._unquote(val) 

23 return cookiedict