Locale middleware with settings.APPEND_SLASH enabled is buggy (doesn't redirect) with valid URLs not ending with slash
|Reported by:||Owned by:||nobody|
|Severity:||Normal||Keywords:||redirect, i18n, locale middleware|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
the locale middleware does not handle the case when settings.APPEND_SLASH is enabled and a valid URL that doesn't end with slash is accessed. Example:
i18n url pattern ^sitemap\.xml$
I access domain.tld/sitemap.xml
The middleware checks if settings.APPEND_SLASH and not language_path.endswith('/') and in that case appends '/' to the url, so we get something like language_path=u'/en/sitemap.xml/'.
That in turn does not match any of the urls because our regexp doesn't allow slash at the end for sitemap.xml and we get 404 instead of redirect to /en/sitemap.xml.
My pull request is at https://github.com/django/django/pull/591
Change History (13)
comment:1 Changed 4 years ago by
|Patch needs improvement:||unset|