Skip to content

Commit

Permalink
validate namespace in disconnect call
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrinberg committed Nov 19, 2019
1 parent 64f63e8 commit 7379d45
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions socketio/base_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ def pre_disconnect(self, sid, namespace):

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:
Expand Down
5 changes: 5 additions & 0 deletions tests/test_base_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ def test_disconnect_with_callbacks(self):
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')
Expand Down

0 comments on commit 7379d45

Please sign in to comment.