#26812: APPEND_SLASH not working correctly with URL ending with slash
-------------------------------+--------------------
Reporter: melwas | Owner: nobody
Type: Uncategorized | Status: new
Component: HTTP handling | Version: 1.9
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
Hi,
In ''middleware/common.py'' there is a code, which checks whether the
slash should be appended to URL.
{{{
def should_redirect_with_slash(self, request):
"""
Return True if settings.APPEND_SLASH is True and appending a slash
to
the request path turns an invalid path into a valid one.
"""
if settings.APPEND_SLASH and not
request.get_full_path().endswith('/'):
urlconf = getattr(request, 'urlconf', None)
return (
not urlresolvers.is_valid_path(request.path_info, urlconf)
and urlresolvers.is_valid_path('%s/' % request.path_info,
urlconf)
)
return False
}}}
In most cases it works fine, but it fails to append slash, when used with
LOGIN_URL without slash and with "next" parameter. For example:
It works fine:'' /accounts/login/?next=/polls/3/'' -> LOGIN_URL =
''/accounts/login/''
But this one returns 404: ''/accounts/login?next=/polls/3/'' -> LOGIN_URL
= ''/accounts/login (no trailing slash).''
It is because: ''request.get_full_path().endswith('/')'' checks also query
string and therefore returns true and the slash is never appended.
--
Ticket URL: <https://code.djangoproject.com/ticket/26812>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/049.b6d992d91da4a274340c82457d57b1c5%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.