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

Ticket #730 (defect)

Opened 3 years ago

Last modified 2 years ago

missing unicode params after tools.decode

Status: closed (fixed)

Reported by: andcycle@andcycle.idv.tw Assigned to: rdelon
Priority: normal Milestone:
Component: CherryPy code Keywords:
Cc:

at /lib/encoding.py

...
def decode_params(encoding):
    decoded_params = {}
    for key, value in cherrypy.request.params.items():
        if hasattr(value, 'file'):
            # This is a file being uploaded: skip it
            decoded_params[key] = value
        elif isinstance(value, list):
            # value is a list: decode each element
            decoded_params[key] = [v.decode(encoding) for v in value]
        elif isinstance(value, unicode):
            pass
        else:
            # value is a regular string: decode it
            decoded_params[key] = value.decode(encoding)
    
    # Decode all or nothing, so we can try again on error.
    cherrypy.request.params = decoded_params

this function is correct process everything except unicode,

it just bypass the unicode,

so we missing the unicode params after assign params back to request

can be fixed by using update

    cherrypy.request.params.update(decoded_params)

or just put back the unicode params

        elif isinstance(value, unicode):
            decoded_params[key] = value

or, maybe we just process all this in-place because this won't alter dict keys

Change History

09/18/07 12:06:36: Modified by fumanchu

  • status changed from new to closed.
  • resolution set to fixed.

Fixed in trunk in [1719].

Hosted by WebFaction

Log in as guest/cpguest to create tickets