Django

Code

Changeset 8715

Show
Ignore:
Timestamp:
08/29/08 14:15:34 (3 months ago)
Author:
jacob
Message:

Fixed #8653: make formtools' security hash more rubust. Silly that I didn't think of this before; thanks to bthomas for providing the obvious fix.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/contrib/formtools/utils.py

    r8597 r8715  
    1616        hash of that. 
    1717        """ 
    18         # Ensure that the hash does not change when a BooleanField's bound 
    19         # data is a string `False' or a boolean False. 
    20         # Rather than re-coding this special behaviour here, we 
    21         # create a dummy BooleanField and call its clean method to get a 
    22         # boolean True or False verdict that is consistent with 
    23         # BooleanField.clean() 
    24         dummy_bool = BooleanField(required=False) 
    25         def _cleaned_data(bf): 
    26             if isinstance(bf.field, BooleanField): 
    27                 return dummy_bool.clean(bf.data) 
    28             return bf.data 
    2918         
    30         data = [(bf.name, _cleaned_data(bf) or '') for bf in form] 
     19        data = [(bf.name, bf.field.clean(bf.data) or '') for bf in form] 
    3120        data.extend(args) 
    3221        data.append(settings.SECRET_KEY)