Kaydet (Commit) 30bdabb2 authored tarafından Malcolm Tredinnick's avatar Malcolm Tredinnick

Fixed #6764 -- Added some error checking around cookie decoding. Thanks,

Michael Axiak.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@7257 bcc190cf-cafb-0310-a4f2-bffc1f526a37
üst 8defa8fd
import os
from Cookie import SimpleCookie
from Cookie import SimpleCookie, CookieError
from pprint import pformat
from urllib import urlencode
from urlparse import urljoin
......@@ -239,8 +239,13 @@ class QueryDict(MultiValueDict):
def parse_cookie(cookie):
if cookie == '':
return {}
c = SimpleCookie()
c.load(cookie)
try:
c = SimpleCookie()
c.load(cookie)
except CookieError:
# Invalid cookie
return {}
cookiedict = {}
for key in c.keys():
cookiedict[key] = c.get(key).value
......
......@@ -31,4 +31,8 @@ GET:{},
POST:{},
COOKIES:{},
META:{}>
>>> from django.http import parse_cookie
>>> parse_cookie('invalid:key=true')
{}
"""
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment