def test_socketio_crashers(self): """ A series of snippets which crash other WebSockets implementations (specifically, Socket.IO) are harmless to this implementation. """ frames = [ """[{"length":1}]""", """{"messages":[{"length":1}]}""", "hello", "hello<script>alert(/xss/)</script>", "hello<img src=x:x onerror=alert(/xss.2/)>", "{", "~m~EVJLFDJP~", ] for frame in frames: prepared = make_hybi00_frame(frame) frames, buf = parse_hybi00_frames(prepared) self.assertEqual(len(frames), 1) self.assertEqual(frames[0], (NORMAL, frame.encode('utf-8'))) self.assertEqual(buf, six.b(""))
def test_make_hybi00(self): """ HyBi-00 frames are really, *really* simple. """ self.assertEqual(make_hybi00_frame("Test!"), six.b("\x00Test!\xff"))