Skip to content

Commit

Permalink
prevent crash when client sends empty event
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrinberg committed Sep 2, 2024
1 parent f147604 commit 1b901de
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/socketio/async_namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async def trigger_event(self, event, *args):
Note: this method is a coroutine.
"""
handler_name = 'on_' + event
handler_name = 'on_' + (event or '')
if hasattr(self, handler_name):
handler = getattr(self, handler_name)
if asyncio.iscoroutinefunction(handler) is True:
Expand Down Expand Up @@ -194,7 +194,7 @@ async def trigger_event(self, event, *args):
Note: this method is a coroutine.
"""
handler_name = 'on_' + event
handler_name = 'on_' + (event or '')
if hasattr(self, handler_name):
handler = getattr(self, handler_name)
if asyncio.iscoroutinefunction(handler) is True:
Expand Down
4 changes: 2 additions & 2 deletions src/socketio/namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def trigger_event(self, event, *args):
method can be overridden if special dispatching rules are needed, or if
having a single method that catches all events is desired.
"""
handler_name = 'on_' + event
handler_name = 'on_' + (event or '')
if hasattr(self, handler_name):
return getattr(self, handler_name)(*args)

Expand Down Expand Up @@ -152,7 +152,7 @@ def trigger_event(self, event, *args):
method can be overridden if special dispatching rules are needed, or if
having a single method that catches all events is desired.
"""
handler_name = 'on_' + event
handler_name = 'on_' + (event or '')
if hasattr(self, handler_name):
return getattr(self, handler_name)(*args)

Expand Down

0 comments on commit 1b901de

Please sign in to comment.