File tree Expand file tree Collapse file tree 3 files changed +19
-1
lines changed
Expand file tree Collapse file tree 3 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -394,6 +394,23 @@ def expires_soon(x,request):
394394def startswith (x , y ):
395395 return str (x ).startswith (y )
396396
397+
398+ @register .filter (name = 'removesuffix' , is_safe = False )
399+ def removesuffix (value , suffix ):
400+ """Remove an exact-match suffix
401+
402+ The is_safe flag is False because indiscriminate use of this could result in non-safe output.
403+ See https://docs.djangoproject.com/en/2.2/howto/custom-template-tags/#filters-and-auto-escaping
404+ which describes the possibility that removing characters from an escaped string may introduce
405+ HTML-unsafe output.
406+ """
407+ base = str (value )
408+ if base .endswith (suffix ):
409+ return base [:- len (suffix )]
410+ else :
411+ return base
412+
413+
397414@register .filter
398415def has_role (user , role_names ):
399416 from ietf .ietfauth .utils import has_role
Original file line number Diff line number Diff line change @@ -95,6 +95,7 @@ def test_login_and_logout(self):
9595 # try logging out
9696 r = self .client .get (urlreverse ('django.contrib.auth.views.logout' ))
9797 self .assertEqual (r .status_code , 200 )
98+ self .assertNotContains (r , "accounts/logout" )
9899
99100 r = self .client .get (urlreverse (ietf .ietfauth .views .profile ))
100101 self .assertEqual (r .status_code , 302 )
Original file line number Diff line number Diff line change 7272 </ ul >
7373 {% if not user.is_authenticated %}
7474 < p class ="navbar-text "> </ p >
75- < a class ="btn {% if server_mode and server_mode == "production " %}btn-warning{% else %}btn-default{% endif %} btn-sm navbar-btn" rel="nofollow " href ="/accounts/login/?next={{request.get_full_path|urlencode}} "> Sign in</ a >
75+ < a class ="btn {% if server_mode and server_mode == "production " %}btn-warning{% else %}btn-default{% endif %} btn-sm navbar-btn" rel="nofollow " href ="/accounts/login/?next={{request.get_full_path|removesuffix: " accounts /logout/"| urlencode}}"> Sign in</ a >
7676 {% endif %}
7777
7878 < form class ="navbar-form navbar-right hidden-xs " action ="/doc/search/ ">
You can’t perform that action at this time.
0 commit comments