Ticket #19488: 19488-1.diff

File 19488-1.diff, 2.7 KB (added by claudep, 2 years ago)
  • django/middleware/locale.py

    diff --git a/django/middleware/locale.py b/django/middleware/locale.py
    index 628782b..f693e4d 100644
    a b class LocaleMiddleware(object): 
    3131                    and self.is_language_prefix_patterns_used()):
    3232            urlconf = getattr(request, 'urlconf', None)
    3333            language_path = '/%s%s' % (language, request.path_info)
    34             if settings.APPEND_SLASH and not language_path.endswith('/'):
    35                 language_path = language_path + '/'
     34            path_valid = is_valid_path(language_path, urlconf)
     35            if (not path_valid and settings.APPEND_SLASH
     36                    and not language_path.endswith('/')):
     37                path_valid = is_valid_path("%s/" % language_path, urlconf)
    3638
    37             if is_valid_path(language_path, urlconf):
     39            if path_valid:
    3840                language_url = "%s://%s/%s%s" % (
    3941                    request.is_secure() and 'https' or 'http',
    4042                    request.get_host(), language, request.get_full_path())
  • tests/regressiontests/i18n/patterns/tests.py

    diff --git a/tests/regressiontests/i18n/patterns/tests.py b/tests/regressiontests/i18n/patterns/tests.py
    index 358cdf6..639e03f 100644
    a b class URLTranslationTests(URLTestCaseBase): 
    115115
    116116        with translation.override('nl'):
    117117            self.assertEqual(reverse('users'), '/nl/gebruikers/')
     118            self.assertEqual(reverse('prefixed_xml'), '/nl/prefixed.xml')
    118119
    119120        with translation.override('pt-br'):
    120121            self.assertEqual(reverse('users'), '/pt-br/usuarios/')
    class URLRedirectWithoutTrailingSlashTests(URLTestCaseBase): 
    186187        self.assertIn(('http://testserver/en/account/register/', 301), response.redirect_chain)
    187188        self.assertRedirects(response, '/en/account/register/', 302)
    188189
     190        response = self.client.get('/prefixed.xml', HTTP_ACCEPT_LANGUAGE='en', follow=True)
     191        self.assertRedirects(response, '/en/prefixed.xml', 302)
     192
    189193
    190194class URLRedirectWithoutTrailingSlashSettingTests(URLTestCaseBase):
    191195    """
  • tests/regressiontests/i18n/patterns/urls/default.py

    diff --git a/tests/regressiontests/i18n/patterns/urls/default.py b/tests/regressiontests/i18n/patterns/urls/default.py
    index f117502..00b90b1 100644
    a b urlpatterns = patterns('', 
    1414
    1515urlpatterns += i18n_patterns('',
    1616    url(r'^prefixed/$', view, name='prefixed'),
     17    url(r'^prefixed\.xml$', view, name='prefixed_xml'),
    1718    url(_(r'^users/$'), view, name='users'),
    1819    url(_(r'^account/'), include('regressiontests.i18n.patterns.urls.namespace', namespace='account')),
    1920)
Back to Top