#20169 closed Bug (fixed)
Request path incorrectly assembled when SCRIPT_NAME has trailing slash
| Reported by: | Julien Phalip | Owned by: | nobody |
|---|---|---|---|
| Component: | HTTP handling | Version: | 1.5 |
| Severity: | Normal | Keywords: | |
| Cc: | bmispelon@… | Triage Stage: | Accepted |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
If the request's SCRIPT_NAME, or the FORCE_SCRIPT_NAME setting, has a trailing slash, then the path is incorrectly assembled and contains one too many slash. See for example:
>>> from io import BytesIO >>> from django.core.handlers.wsgi import WSGIRequest >>> request = WSGIRequest({'PATH_INFO': '/somepath/', 'SCRIPT_NAME': '/PREFIX/', 'REQUEST_METHOD': 'get', 'wsgi.input': BytesIO(b'')}) >>> request.path u'/PREFIX//somepath/'
The attached pull request should fix this in a backwards-compatible way.
Change History (5)
comment:1 by , 13 years ago
comment:2 by , 13 years ago
| Cc: | added |
|---|---|
| Triage Stage: | Unreviewed → Accepted |
The patch looks good but there's a typo in the test's docstrings: s/regarless/regardless/ (2 occurences).
Also, as you noted, there's currently no tests for the FORCE_SCRIPT_NAME feature. Maybe this would be a good occation to add one (checking that FORCE_SCRIPT_NAME does indeed overwrite the request's SCRIPT_NAME).
comment:3 by , 13 years ago
Thanks for the suggestion. I've added a test to the PR and will be pushing this shortly.
comment:4 by , 13 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Here's the pull request: https://github.com/django/django/pull/980
The added benefit of that patch is that it adds tests for the
FORCE_SCRIPT_NAMEwhich didn't seem to be tested at all before.