File tree Expand file tree Collapse file tree 3 files changed +29
-35
lines changed Expand file tree Collapse file tree 3 files changed +29
-35
lines changed Original file line number Diff line number Diff line change 1
- Upcoming
2
- ********
1
+ 0.38.0 (2018-10-03)
2
+ *******************
3
+
4
+ Security notice
5
+ ---------------
6
+
7
+ The ``{% user_display user %} `` tag did not escape properly. Depending on the
8
+ username validation rules, this could lead to XSS issues.
9
+
3
10
4
11
Note worthy changes
5
- ------------------------------
12
+ -------------------
13
+
14
+ - New provider: Vimeo (OAuth2).
6
15
7
- - New translation : Basque.
16
+ - New translations : Basque.
8
17
9
18
10
19
0.37.1 (2018-08-27)
Original file line number Diff line number Diff line change 6
6
register = template .Library ()
7
7
8
8
9
- class UserDisplayNode (template .Node ):
10
-
11
- def __init__ (self , user , as_var = None ):
12
- self .user_var = template .Variable (user )
13
- self .as_var = as_var
14
-
15
- def render (self , context ):
16
- user = self .user_var .resolve (context )
17
-
18
- display = user_display (user )
19
-
20
- if self .as_var :
21
- context [self .as_var ] = display
22
- return ""
23
- return display
24
-
25
-
26
- @register .tag (name = "user_display" )
27
- def do_user_display (parser , token ):
9
+ @register .simple_tag (name = 'user_display' )
10
+ def user_display_tag (user ):
28
11
"""
29
12
Example usage::
30
13
@@ -38,15 +21,4 @@ def do_user_display(parser, token):
38
21
{% endblocktrans %}
39
22
40
23
"""
41
- bits = token .split_contents ()
42
- if len (bits ) == 2 :
43
- user = bits [1 ]
44
- as_var = None
45
- elif len (bits ) == 4 :
46
- user = bits [1 ]
47
- as_var = bits [3 ]
48
- else :
49
- raise template .TemplateSyntaxError (
50
- "'%s' takes either two or four arguments" % bits [0 ])
51
-
52
- return UserDisplayNode (user , as_var )
24
+ return user_display (user )
Original file line number Diff line number Diff line change 12
12
from django .core .exceptions import ValidationError
13
13
from django .db import models
14
14
from django .http import HttpResponseRedirect
15
+ from django .template import Context , Template
15
16
from django .test .client import Client , RequestFactory
16
17
from django .test .utils import override_settings
17
18
from django .urls import reverse
@@ -1126,6 +1127,18 @@ def test_username_case_preserved(self):
1126
1127
# TODO: Actually test something
1127
1128
filter_users_by_username ('camelcase' , 'foobar' )
1128
1129
1130
+ def test_user_display (self ):
1131
+ user = get_user_model ()(username = 'john<br/>doe' )
1132
+ expected_name = 'john<br/>doe'
1133
+ templates = [
1134
+ '{% load account %}{% user_display user %}' ,
1135
+ '{% load account %}{% user_display user as x %}{{ x }}'
1136
+ ]
1137
+ for template in templates :
1138
+ t = Template (template )
1139
+ content = t .render (Context ({'user' : user }))
1140
+ self .assertEqual (content , expected_name )
1141
+
1129
1142
1130
1143
class ConfirmationViewTests (TestCase ):
1131
1144
def _create_user (self , username = 'john' , password = 'doe' ):
You can’t perform that action at this time.
0 commit comments