Skip to content

Commit 5daae70

Browse files
committed
Fix Lawouach#44, when no masking was done, we must ensure we are dealing with a bytearray instance as this is what utf8validator expects
1 parent bbf727a commit 5daae70

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

ws4py/streaming.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def receiver(self):
254254
reason = 'Invalid Closing Frame Code: %d' % code
255255
code = 1002
256256
elif frame.payload_length > 1:
257-
reason = bytes[2:] if frame.masking_key else frame.body[2:]
257+
reason = bytes[2:] if frame.masking_key else bytearray(frame.body[2:])
258258
is_valid, end_on_code_point, _, _ = utf8validator.validate(reason)
259259
if not is_valid or not end_on_code_point:
260260
self.errors.append(CloseControlMessage(code=1007, reason='Invalid UTF-8 bytes'))

0 commit comments

Comments
 (0)