Changes between Initial Version and Version 1 of Ticket #12464
- Timestamp:
- Dec 29, 2009, 5:43:42 PM (15 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #12464 – Description
initial v1 1 1 Take the following Apache config snippet: 2 2 3 {{{ 3 4 RewriteEngine On 4 5 WSGIScriptAlias /project /django/project/bin/django.wsgi 6 }}} 5 7 6 8 This results in mod_rewrite setting the SCRIPT_URL environment variable. … … 8 10 The code at http://code.djangoproject.com/browser/django/tags/releases/1.1.1/django/core/handlers/base.py#L204: 9 11 12 {{{ 10 13 script_url = environ.get('SCRIPT_URL', u'') 11 14 if not script_url: … … 14 17 return force_unicode(script_url[:-len(environ.get('PATH_INFO', ''))]) 15 18 return force_unicode(environ.get('SCRIPT_NAME', u'')) 19 }}} 16 20 17 21 ...behaves incorrectly when, in the above example, /project is requested from Apache. … … 19 23 The problem is when PATH_INFO is empty, as it is in this case. Python 20 24 has no notion of positive or negative zero (;-)) so we end up returning 21 script_url[:0]. This results in request.META['SCRIPT_NAME'] being set to '', which in turn results in urls being generated incorrectly.25 `script_url[:0]`. This results in `request.META['SCRIPT_NAME']`being set to `''`, which in turn results in urls being generated incorrectly. 22 26 23 A workaround for this is to add the following rewrite rule before WSGIScriptAlias:27 A workaround for this is to add the following rewrite rule before !WSGIScriptAlias: 24 28 29 {{{ 25 30 RewriteRule ^/project$ /project/ [R] 31 }}} 26 32 27 33 This bug is potentially related to #9435, but this is ticket describes a real world problem that I believe has bitten more people than just me... … … 29 35 A solution for this could well just be to change the section to: 30 36 37 {{{ 31 38 if script_url: 32 39 path_info = environ.get('PATH_INFO', '') … … 35 42 return force_unicode(script_url) 36 43 return force_unicode(environ.get('SCRIPT_NAME', u'')) 44 }}} 37 45 38 46 ...but I have no idea where to go about writing a test.