Browse Source

prevent crash when client sends empty event

pull/1381/head
Miguel Grinberg 7 months ago
parent
commit
1b901de007
Failed to extract signature
  1. 4
      src/socketio/async_namespace.py
  2. 4
      src/socketio/namespace.py

4
src/socketio/async_namespace.py

@ -29,7 +29,7 @@ class AsyncNamespace(base_namespace.BaseServerNamespace):
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:
@ -194,7 +194,7 @@ class AsyncClientNamespace(base_namespace.BaseClientNamespace):
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:

4
src/socketio/namespace.py

@ -21,7 +21,7 @@ class Namespace(base_namespace.BaseServerNamespace):
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)
@ -152,7 +152,7 @@ class ClientNamespace(base_namespace.BaseClientNamespace):
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)

Loading…
Cancel
Save