Ticket #507 (defect)
Opened 2 years ago
Last modified 2 years ago
InternalRedirect supports only absolute paths
Status: closed (fixed)
| Reported by: | anonymous | Assigned to: | fumanchu |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.0 |
| Component: | CherryPy code | Keywords: | redirect InternalRedirect |
| Cc: |
using InternalRedirect('foo', params=params) fails, because unlike HTTPRedirect, it does not urljoin the path argument with the request's current path.
Here is a short diff adding urljoin:
Index: _cperror.py
===================================================================
RCS file: /cvs/third-party/CherryPy/cherrypy/_cperror.py,v
retrieving revision 1.1.1.1
diff -u -p -b -r1.1.1.1 _cperror.py
--- _cperror.py 27 Mar 2006 05:31:03 -0000 1.1.1.1
+++ _cperror.py 12 Apr 2006 16:23:38 -0000
@@ -31,11 +31,16 @@ class InternalRedirect(Exception):
def __init__(self, path, params=None):
import cherrypy
import cgi
+ import urlparse
request = cherrypy.request
# Set a 'path' member attribute so that code which traps this
# error can have access to it.
- self.path = path
+ #
+ # Note that urljoin will "do the right thing" whether url is:
+ # 1. a URL relative to root (e.g. "/dummy")
+ # 2. a URL relative to the current path
+ self.path = urlparse.urljoin(request.object_path, path)
if params is not None:
if isinstance(params, basestring):
Attachments
Change History
04/12/06 11:25:29: Modified by dowski
- description changed.
04/12/06 11:27:31: Modified by anonymous
- attachment ir_urljoin.diff added.
05/10/06 02:51:11: Modified by fumanchu
- owner changed from rdelon to fumanchu.
- status changed from new to assigned.
- milestone set to 3.0.
06/08/06 00:51:10: Modified by fumanchu
- status changed from assigned to closed.
- resolution set to fixed.
Fixed in [1128].
12/09/06 16:59:53: Modified by fumanchu
2.x fix in [1496].


Diff adding urljoin to InternalRedirect? functionality.