This repository was archived by the owner on Oct 23, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +12
-2
lines changed Expand file tree Collapse file tree 3 files changed +12
-2
lines changed Original file line number Diff line number Diff line change 99
1010import re
1111
12- from raven .utils .compat import string_types , text_type
12+ from raven .utils .compat import string_types , text_type , PY3
1313from raven .utils import varmap
1414
1515
@@ -110,6 +110,10 @@ def filter_http(self, data):
110110 if n not in data :
111111 continue
112112
113+ # data could be provided as bytes
114+ if PY3 and isinstance (data [n ], bytes ):
115+ data [n ] = data [n ].decode ('utf-8' , 'replace' )
116+
113117 if isinstance (data [n ], string_types ) and '=' in data [n ]:
114118 # at this point we've assumed it's a standard HTTP query
115119 # or cookie
Original file line number Diff line number Diff line change @@ -209,7 +209,7 @@ def test_djangorestframeworkcompatmiddleware_fills_request_data(self):
209209 content_type = 'application/json' )
210210 assert len (self .raven .events ) == 1
211211 event = self .raven .events .pop (0 )
212- assert event ['request' ]['data' ] == b '{"a":"b"}'
212+ assert event ['request' ]['data' ] == '{"a":"b"}'
213213
214214 def test_capture_event_with_request_middleware (self ):
215215 path = reverse ('sentry-trigger-event' )
Original file line number Diff line number Diff line change @@ -357,6 +357,12 @@ def test_sanitize_non_ascii(self):
357357 result = proc .sanitize ('__repr__: жили-были' , '42' )
358358 self .assertEquals (result , '42' )
359359
360+ def test_sanitize_bytes (self ):
361+ proc = SanitizePasswordsProcessor (Mock ())
362+ data = {'data' : b'password=1234' }
363+ result = proc .filter_http (data )
364+ self .assertIn (data ['data' ], 'password=%s' % proc .MASK )
365+
360366
361367class RemovePostDataProcessorTest (TestCase ):
362368 def test_does_remove_data (self ):
You can’t perform that action at this time.
0 commit comments