Ticket #6764: safe_cookie.diff
File safe_cookie.diff, 1.1 KB (added by , 17 years ago) |
---|
-
django/http/__init__.py
1 1 import os 2 from Cookie import SimpleCookie 2 from Cookie import SimpleCookie, CookieError 3 3 from pprint import pformat 4 4 from urllib import urlencode 5 5 from urlparse import urljoin … … 239 239 def parse_cookie(cookie): 240 240 if cookie == '': 241 241 return {} 242 c = SimpleCookie() 243 c.load(cookie) 242 try: 243 c = SimpleCookie() 244 c.load(cookie) 245 except CookieError: 246 # Invalid cookie 247 return {} 248 244 249 cookiedict = {} 245 250 for key in c.keys(): 246 251 cookiedict[key] = c.get(key).value -
tests/regressiontests/requests/tests.py
31 31 POST:{}, 32 32 COOKIES:{}, 33 33 META:{}> 34 35 >>> from django.http import parse_cookie 36 >>> parse_cookie('invalid:key=true') 37 {} 34 38 """