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

Ticket #123 (defect)

Opened 4 years ago

Last modified 3 years ago

Redirect bug

Status: closed (fixed)

Reported by: Michal Zylinski Assigned to: rdelon
Priority: high Milestone: 2.0-final
Component: CherryPy code Keywords:
Cc:

I found some slightly annoying bug in httplib.redirect function, that appears when using certain url parameters. The easy way to reproduce it is to try to make a redirect from url like:

http://mysite/index?param=http://anothersite

Instead of using cherrypy's own url tokenizing logic I simply suggest to use standard urlparse module. Following code works perfectly for me, and IMHO is much more cleaner.

from urlparse import urljoin

def redirect(newUrl):

""" Sends a redirect to the browser """ newUrl = urljoin(cpg.request.browserUrl, newUrl) cpg.response.headerMap['Status'] = 302 cpg.response.headerMap['Location'] = newUrl return

Also instead of returning list it now returns string, as previously it could have generated some problems.

Change History

04/12/05 12:04:00: Modified by rdelon

  • milestone set to 2.0-final.

04/24/05 11:06:12: Modified by rdelon

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

Fixed in changeset #156

Hosted by WebFaction

Log in as guest/cpguest to create tickets