Browse Source

validate namespace in disconnect call

Fixes https://github.com/miguelgrinberg/Flask-SocketIO/issues/427
pull/14/merge
Miguel Grinberg 8 years ago
parent
commit
3ae013b90e
  1. 2
      socketio/base_manager.py
  2. 5
      tests/test_base_manager.py

2
socketio/base_manager.py

@ -64,6 +64,8 @@ class BaseManager(object):
def disconnect(self, sid, namespace):
"""Register a client disconnect from a namespace."""
if namespace not in self.rooms:
return
rooms = []
for room_name, room in six.iteritems(self.rooms[namespace]):
if sid in room:

5
tests/test_base_manager.py

@ -99,6 +99,11 @@ class TestBaseManager(unittest.TestCase):
self.bm.disconnect('123', '/')
self.assertNotIn('123', self.bm.callbacks)
def test_disconnect_bad_namespace(self):
self.bm.connect('123', '/')
self.bm.connect('123', '/foo')
self.bm.disconnect('123', '/bar') # should not assert
def test_trigger_callback(self):
self.bm.connect('123', '/')
self.bm.connect('123', '/foo')

Loading…
Cancel
Save