Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 1722

Show
Ignore:
Timestamp:
09/20/07 17:27:56
Author:
fumanchu
Message:

Fix for #732 (tools.decode and non str params).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/lib/encoding.py

    r1719 r1722  
    3535    decoded_params = {} 
    3636    for key, value in cherrypy.request.params.items(): 
    37         if hasattr(value, 'file'): 
    38             # This is a file being uploaded: skip it 
    39             decoded_params[key] = value 
    40         elif isinstance(value, list): 
    41             # value is a list: decode each element 
    42             decoded_params[key] = [v.decode(encoding) for v in value] 
    43         elif isinstance(value, unicode): 
    44             decoded_params[key] = value 
    45         else: 
    46             # value is a regular string: decode it 
    47             decoded_params[key] = value.decode(encoding) 
     37        if not hasattr(value, 'file'): 
     38            # Skip the value if it is an uploaded file 
     39            if isinstance(value, list): 
     40                # value is a list: decode each element 
     41                value = [v.decode(encoding) for v in value] 
     42            elif isinstance(value, str): 
     43                # value is a regular string: decode it 
     44                value = value.decode(encoding) 
     45        decoded_params[key] = value 
    4846     
    4947    # Decode all or nothing, so we can try again on error. 

Hosted by WebFaction

Log in as guest/cpguest to create tickets