Ticket #433 (defect)
Opened 3 years ago
Last modified 2 years ago
[PATCH] mapPathToObject should remove a trailing /, not just add it!
Status: closed (fixed)
| Reported by: | anonymous | Assigned to: | rdelon |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | CherryPy code | Keywords: | |
| Cc: |
Observe _cphttptools.py, method mapPathToObject..
If the request path was "/foo/bar" and "bar" has an index() method, then we will be redirected to "/foo/bar/". Good!
But if the request path was "/foo/bar/" and "bar" DOESN'T have an index() method, then we WON'T be redirected to "/foo/bar". Bad!
So I propose that for objects without an index method, to be redirected to the location with the trailing / removed! This will have the nice effect of ensuring that relative URLs don't break if people decide to go to the URL with a /!
(urls like "/foo/bar/?apple=orange" should also be fixed to "/foo/bar?apple=orange"
Attachments
Change History
01/04/06 12:47:47: Modified by fumanchu
- description changed.
01/05/06 18:23:30: Modified by anonymous
- summary changed from mapPathToObject should remove a trailing /, not just add it! to [PATCH] mapPathToObject should remove a trailing /, not just add it!.
01/05/06 18:24:05: Modified by anonymous
- attachment _cphttptools.patch added.
08/30/06 19:03:22: Modified by fumanchu
- status changed from new to closed.
- resolution set to fixed.
Fixed in [1303]. Configure missing or extra slash behavior via request.redirect_on_missing_slash and request.redirect_on_extra_slash.


I've added a patch. To clear things up, it does not check if index is a callab,e just like the original mapPathToObject it simply checks if the index is an attribute or not of the path.