Changes between Initial Version and Version 6 of Ticket #17133


Ignore:
Timestamp:
10/23/2012 09:08:47 AM (3 years ago)
Author:
claudep
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #17133

    • Property Status changed from new to reopened
    • Property Has patch set
  • Ticket #17133 – Description

    initial v6  
    1 When running under Apache+mod_wsgi (I'm not sure the mod_wsgi is relevant here), using a WSGIScriptAlias of /foo, a request for URL /foo/bar//baz (note double slash) gets transformed by Apache to /foo/bar/baz and then by Django to /foo//bar/baz (note where double slashes are now).  Furthermore, a callback function for urlpattern "^bar/.*" will be called on this latter path even though it doesn't match the pattern.  That is, request.path will be "/foo//bar/baz", which can be confusing for a callback function that is expecting request.path to match the WSGIScriptAlias plus the urlpattern.
     1When running under Apache+mod_wsgi (I'm not sure the mod_wsgi is relevant here), using a WSGIScriptAlias of `/foo`, a request for URL `/foo/bar//baz` (note double slash) gets transformed by Apache to `/foo/bar/baz` and then by Django to `/foo//bar/baz` (note where double slashes are now).  Furthermore, a callback function for urlpattern `"^bar/.*"` will be called on this latter path even though it doesn't match the pattern.  That is, request.path will be `/foo//bar/baz`, which can be confusing for a callback function that is expecting request.path to match the WSGIScriptAlias plus the urlpattern.
    22
    3 I don't totally understand what Django is doing here, but I believe the problem is in django.core.handlers.base.get_script_name.  In that function, to get the script name in this situation Django starts with the environment variable SCRIPT_URL, and strips off a number of characters at the end equal to the length of environment variable PATH_INFO.  Because in this case Apache collapses the double slash in /foo/bar//baz to /foo/bar/baz, get_script_name strips off one less character than necessary, so that instead of the script name being /foo it is /foo/.  This may account for the double slash appearing /foo, as in /foo//bar/baz.
     3I don't totally understand what Django is doing here, but I believe the problem is in django.core.handlers.base.get_script_name.  In that function, to get the script name in this situation Django starts with the environment variable SCRIPT_URL, and strips off a number of characters at the end equal to the length of environment variable PATH_INFO.  Because in this case Apache collapses the double slash in `/foo/bar//baz` to `/foo/bar/baz`, get_script_name strips off one less character than necessary, so that instead of the script name being `/foo` it is `/foo/`.  This may account for the double slash appearing `/foo`, as in `/foo//bar/baz`.
Back to Top