Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #899 (closed defect: invalid)

Opened 13 years ago

Last modified 12 years ago

turbogears.url misunderstands same-name fields from cherrypy.paramMap

Reported by: anonymous Owned by: anonymous
Priority: normal Milestone: 1.0
Component: CherryPy Version: 0.9a1
Severity: minor Keywords:
Cc:

Description

I have a login page which users get redirected to, which rebuilds the original URL using

previous_url=turbogears.url(cherrypy.request.path,cherrypy.request.paramMap)

this fails when you have e.g.

 http://mysite/wherever?a=4&a=7

because paramMap joins these into a list {a:[4,7]} and turbogears.url encodes the list as a string, so turbogears.url produces (an escaped version of)

 http://mysite/wherever?a=[4,7]

it looks like in turbogears/controllers.py you'd need something like

 489    for key, value in tgparams.iteritems():
           if not isinstance(value,list):
                value=[value]
           for subvalue in value:
 490 	        if subvalue is None:
 491 	            continue
 492 	        if isinstance(subvalue, unicode):
 493 	            value = subvalue.encode("utf8")
 494 	        args.append("%s=%s" % (key, urllib.quote(str(subvalue))))

that's probably bad programming but you get the idea. I haven't experimented with what cherrypy.paramMap does in more obscure cases.

Change History

comment:1 Changed 13 years ago by jorge.vargas

  • Milestone set to 1.0

can someone confirm or deny this?

comment:2 Changed 13 years ago by fumanchu@…

You should probably be passing and using cherrypy.request.query_string instead of paramMap, both to avoid the list bug, and because the latter also includes both GET and POST params. If there's good reason to include the POST (request-body) params, I'd like to know it :) so it can be provided in the new cherrypy.url() function in CP 3.

comment:3 Changed 13 years ago by jorge.vargas

  • Status changed from new to closed
  • Resolution set to invalid

not a bug just bad usage.

Note: See TracTickets for help on using tickets.