summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2015-10-24 11:14:17 +0200
committerClaude Paroz <claude@2xlibre.net>2015-10-27 14:29:18 +0100
commitea2f48ce8bd865874108af79766cdef2d197e540 (patch)
tree3656475a3c1cc00ee982cbf7ac2de3e292fd91c6
parentc4b4a7430b06451e23686d6533b98109dbdcd792 (diff)
Refs #17133 -- Optimized script_url handling in get_script_name
10ace52a added some regex processing for each request with SCRIPT_URL set. In a speed critical section, conditionally apply of the regex will save some resources.
-rw-r--r--django/core/handlers/wsgi.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/django/core/handlers/wsgi.py b/django/core/handlers/wsgi.py
index 52f5cc5c59..cd3dfb2305 100644
--- a/django/core/handlers/wsgi.py
+++ b/django/core/handlers/wsgi.py
@@ -221,9 +221,10 @@ def get_script_name(environ):
script_url = get_bytes_from_wsgi(environ, 'REDIRECT_URL', '')
if script_url:
- # mod_wsgi squashes multiple successive slashes in PATH_INFO,
- # do the same with script_url before manipulating paths (#17133).
- script_url = _slashes_re.sub(b'/', script_url)
+ if b'//' in script_url:
+ # mod_wsgi squashes multiple successive slashes in PATH_INFO,
+ # do the same with script_url before manipulating paths (#17133).
+ script_url = _slashes_re.sub(b'/', script_url)
path_info = get_bytes_from_wsgi(environ, 'PATH_INFO', '')
script_name = script_url[:-len(path_info)] if path_info else script_url
else: