File tree Expand file tree Collapse file tree 2 files changed +6
-8
lines changed
Expand file tree Collapse file tree 2 files changed +6
-8
lines changed Original file line number Diff line number Diff line change 99from django .core .exceptions import ValidationError
1010from django .db import connections
1111from django .utils .crypto import constant_time_compare
12- from django .utils .encoding import force_text
12+ from django .utils .encoding import force_bytes
1313from django .utils .functional import cached_property
1414
1515from debug_toolbar .panels .sql .utils import reformat_sql
@@ -79,12 +79,10 @@ def reformat_sql(self):
7979 return reformat_sql (self .cleaned_data ['sql' ])
8080
8181 def make_hash (self , data ):
82- items = [data ['sql' ], data ['params' ]]
83- # Replace lines endings with spaces to preserve the hash value
84- # even when the browser normalizes \r\n to \n in inputs.
85- items = [' ' .join (force_text (item ).splitlines ()) for item in items ]
86- return hmac .new (settings .SECRET_KEY .encode ('utf-8' ),
87- '' .join (items ).encode ('utf-8' ), hashlib .sha1 ).hexdigest ()
82+ m = hmac .new (key = force_bytes (settings .SECRET_KEY ), digestmod = hashlib .sha1 )
83+ for item in [data ['sql' ], data ['params' ]]:
84+ m .update (force_bytes (item ))
85+ return m .hexdigest ()
8886
8987 @property
9088 def connection (self ):
Original file line number Diff line number Diff line change 77
88# Quick-start development settings - unsuitable for production
99
10- SECRET_KEY = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'
10+ SECRET_KEY = bytes ( bytearray ([ i for i in range ( 256 )]))
1111
1212INTERNAL_IPS = ['127.0.0.1' ]
1313
You can’t perform that action at this time.
0 commit comments