#23173: SCRIPT_URL on WSGI is misinterpreted when PATH_INFO is empty
-------------------------+-------------------------------------------------
Reporter: j-sz@… | Owner: nobody
Type: Bug | Status: new
Component: Core | Version: master
(URLs) | Keywords: wsgi, script name, negative index
Severity: Normal | slicing
Triage Stage: | Has patch: 0
Unreviewed | UI/UX: 0
Easy pickings: 0 |
-------------------------+-------------------------------------------------
This bug is pretty obvious. In the dev version it's in
django/core/handlers/wsgi.py:235 in get_script_name; in 1.5.1 (where I've
found it) it's in django/core/handlers/base.py:280. I haven't checked how
long it's been there.
The problem is due to slicing with a negative end index:
{{{
script_name = script_url[:-len(path_info)]
}}}
It works fine as long as path_info is not empty. On my system it was empty
and the whole script_url was truncated.
I've grepped the source tree for `'\[:-[^0-9]'` to check if there are some
other instances of this pattern and it returned a couple of results. I'd
suggest examining them and making sure the indices are non-zero.
A patch would be trivial, but I'm not giving it, because I feel that a
general function 'chop off n elements from the end' might be handy and I'm
not sure where to put it.
--
Ticket URL: <https://code.djangoproject.com/ticket/23173>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/053.fe9bcab8c9b6c6394cfd897d10655d3d%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.