Ticket #1622 (closed defect: fixed)

Opened 5 months ago

Last modified 5 months ago

VisitFilter breaks when request has list parameters

Reported by: roger.demetrescu Assigned to: roger.demetrescu
Priority: high Milestone: 1.0.4
Component: TurboGears Version: 1.0.4b3
Severity: major Keywords:
Cc:

Description

r3771 breaks calls to exposed methods when Identity is on and there are repeated parameters (aka list parameters), like:

http://localhost:8080/test?foo=1&foo=2

Here is the traceback:

Traceback (most recent call last):
  File "c:\python25\lib\site-packages\cherrypy-2.2.1-py2.5.egg\cherrypy\_cphttptools.py", line 103, in _run
    applyFilters('before_main')
  File "c:\python25\lib\site-packages\cherrypy-2.2.1-py2.5.egg\cherrypy\filters\__init__.py", line 151, in applyFilters
    method()
  File "c:\turbogears1.0\turbogears\visit\api.py", line 223, in before_main
    cherrypy.request.params = encode_utf8(cherrypy.request.params)
  File "c:\turbogears1.0\turbogears\visit\api.py", line 184, in encode_utf8
    res[k] = encode_utf8(v)
  File "c:\turbogears1.0\turbogears\visit\api.py", line 187, in encode_utf8
    res[k] = v.encode('utf-8')
AttributeError: 'list' object has no attribute 'encode'

Change History

12/04/07 20:55:21 changed by roger.demetrescu

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

Fixed in r3807.

12/13/07 05:27:51 changed by chrisz

As discussed on the mailing list, this fix was still not complete. For instance it did not handle the case of a list of dicts (url?a-1.b=1&a-2.b=2).

The fix in r3817 should now really handle all cases. I have also added a better unit test that does not only test that we don't break anything completely, but also checks whether the encoding works correctly.