Django

Code

Changeset 7257

Show
Ignore:
Timestamp:
03/17/08 08:49:04 (4 months ago)
Author:
mtredinnick
Message:

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

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/http/__init__.py

    r7205 r7257  
    11import os 
    2 from Cookie import SimpleCookie 
     2from Cookie import SimpleCookie, CookieError 
    33from pprint import pformat 
    44from urllib import urlencode 
     
    240240    if cookie == '': 
    241241        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 
    244249    cookiedict = {} 
    245250    for key in c.keys(): 
  • django/trunk/tests/regressiontests/requests/tests.py

    r7207 r7257  
    3232COOKIES:{}, 
    3333META:{}> 
     34 
     35>>> from django.http import parse_cookie 
     36>>> parse_cookie('invalid:key=true') 
     37{} 
    3438"""