plugin XEP-0166: reject session creation is session ID is empty

This commit is contained in:
Goffi 2023-08-16 18:28:32 +02:00
commit 71cfdccb5b

View file

@ -184,6 +184,10 @@ class XEP_0166:
@raise ValueError: If the provided role is neither initiator nor responder.
"""
# TODO: session cleaning after timeout ?
if not sid:
raise exceptions.DataError("Empty session ID is not allowed")
if role not in [XEP_0166.ROLE_INITIATOR, XEP_0166.ROLE_RESPONDER]:
raise ValueError(f"Invalid role {role}. Expected initiator or responder.")