File tree Expand file tree Collapse file tree 3 files changed +11
-0
lines changed Expand file tree Collapse file tree 3 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,9 @@ Pending bugfix release.
12
12
made the filter not work properly in HTML attributes. Now it's
13
13
possible to use that filter in single quoted attributes. This should
14
14
make using that filter with angular.js easier.
15
+ - Added support for byte strings back to the session system. This broke
16
+ compatibility with the common case of people putting binary data for
17
+ token verification into the session.
15
18
16
19
Version 0.10
17
20
------------
Original file line number Diff line number Diff line change 11
11
12
12
import uuid
13
13
import hashlib
14
+ from base64 import b64encode , b64decode
14
15
from datetime import datetime
15
16
from werkzeug .http import http_date , parse_date
16
17
from werkzeug .datastructures import CallbackDict
@@ -62,6 +63,8 @@ def _tag(value):
62
63
return {' t' : [_tag (x ) for x in value ]}
63
64
elif isinstance (value , uuid .UUID ):
64
65
return {' u' : value .hex }
66
+ elif isinstance (value , bytes ):
67
+ return {' b' : b64encode (value ).decode ('ascii' )}
65
68
elif callable (getattr (value , '__html__' , None )):
66
69
return {' m' : text_type (value .__html__ ())}
67
70
elif isinstance (value , list ):
@@ -90,6 +93,8 @@ def object_hook(obj):
90
93
return tuple (the_value )
91
94
elif the_key == ' u' :
92
95
return uuid .UUID (the_value )
96
+ elif the_key == ' b' :
97
+ return b64decode (the_value )
93
98
elif the_key == ' m' :
94
99
return Markup (the_value )
95
100
elif the_key == ' d' :
Original file line number Diff line number Diff line change @@ -326,6 +326,7 @@ def modify_session(response):
326
326
flask .session ['m' ] = flask .Markup ('Hello!' )
327
327
flask .session ['u' ] = the_uuid
328
328
flask .session ['dt' ] = now
329
+ flask .session ['b' ] = b'\xff '
329
330
flask .session ['t' ] = (1 , 2 , 3 )
330
331
return response
331
332
@@ -340,6 +341,8 @@ def dump_session_contents():
340
341
self .assert_equal (type (rv ['m' ]), flask .Markup )
341
342
self .assert_equal (rv ['dt' ], now )
342
343
self .assert_equal (rv ['u' ], the_uuid )
344
+ self .assert_equal (rv ['b' ], b'\xff ' )
345
+ self .assert_equal (type (rv ['b' ]), bytes )
343
346
self .assert_equal (rv ['t' ], (1 , 2 , 3 ))
344
347
345
348
def test_flashes (self ):
You can’t perform that action at this time.
0 commit comments