summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2013-01-11 21:27:51 +0100
committerClaude Paroz <claude@2xlibre.net>2013-01-11 21:35:45 +0100
commitb3887ab98ac5317ebe7889e8b35752ebfd9740f9 (patch)
tree9723c9d7b70009021802b0f94e2cb3424edc0444 /django
parent1d03ff06bbcc726c815f26f79067692019b2c71a (diff)
[1.5.x] Fixed #19488 -- Made i18n_patterns redirect work with non-slash-ending paths
Thanks Daniel Gerzo for the report and the initial patch. Backport of bcdb4898c from master.
Diffstat (limited to 'django')
-rw-r--r--django/middleware/locale.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/django/middleware/locale.py b/django/middleware/locale.py
index 628782b181..f693e4d242 100644
--- a/django/middleware/locale.py
+++ b/django/middleware/locale.py
@@ -31,10 +31,12 @@ class LocaleMiddleware(object):
and self.is_language_prefix_patterns_used()):
urlconf = getattr(request, 'urlconf', None)
language_path = '/%s%s' % (language, request.path_info)
- if settings.APPEND_SLASH and not language_path.endswith('/'):
- language_path = language_path + '/'
+ path_valid = is_valid_path(language_path, urlconf)
+ if (not path_valid and settings.APPEND_SLASH
+ and not language_path.endswith('/')):
+ path_valid = is_valid_path("%s/" % language_path, urlconf)
- if is_valid_path(language_path, urlconf):
+ if path_valid:
language_url = "%s://%s/%s%s" % (
request.is_secure() and 'https' or 'http',
request.get_host(), language, request.get_full_path())