Log in and log out require escape and mark_safe

This commit is contained in:
Tom Christie 2015-08-28 10:27:49 +01:00
parent 24a2c3f5c3
commit a5ddd90df0

View File

@ -41,8 +41,9 @@ def optional_login(request):
except NoReverseMatch: except NoReverseMatch:
return '' return ''
snippet = "<li><a href='{href}?next={next}'>Log in</a></li>".format(href=login_url, next=escape(request.path)) snippet = "<li><a href='{href}?next={next}'>Log in</a></li>"
return snippet snippet = snippet.format(href=login_url, next=escape(request.path))
return mark_safe(snippet)
@register.simple_tag @register.simple_tag
@ -64,8 +65,8 @@ def optional_logout(request, user):
<li><a href='{href}?next={next}'>Log out</a></li> <li><a href='{href}?next={next}'>Log out</a></li>
</ul> </ul>
</li>""" </li>"""
snippet = snippet.format(user=escape(user), href=logout_url, next=escape(request.path))
return snippet.format(user=user, href=logout_url, next=escape(request.path)) return mark_safe(snippet)
@register.simple_tag @register.simple_tag