From 8eb5cb0cdcd1314d6d763df8f226b587a2396aa2 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Tue, 23 Oct 2018 16:31:07 +0200 Subject: [PATCH] Explicitly deny text messages We can't really handle them, but let's respond with an explicit error rather than "unknown opcode". --- websockify/websocket.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/websockify/websocket.py b/websockify/websocket.py index e37af0f..3ea0328 100644 --- a/websockify/websocket.py +++ b/websockify/websocket.py @@ -571,6 +571,8 @@ class WebSocket(object): msg = self._partial_msg self._partial_msg = ''.decode("ascii") return msg + elif frame["opcode"] == 0x1: + self.shutdown(socket.SHUT_RDWR, 1003, "Unsupported: Text frames are not supported") elif frame["opcode"] == 0x2: if self._partial_msg: self.shutdown(socket.SHUT_RDWR, 1002, "Procotol error: Unexpected new frame")