diff options
| author | Claude Paroz <claude@2xlibre.net> | 2013-01-11 21:27:51 +0100 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2013-01-11 21:35:45 +0100 |
| commit | b3887ab98ac5317ebe7889e8b35752ebfd9740f9 (patch) | |
| tree | 9723c9d7b70009021802b0f94e2cb3424edc0444 /django | |
| parent | 1d03ff06bbcc726c815f26f79067692019b2c71a (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.py | 8 |
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()) |
