Validate subscribe payload format in realtime message handling

This commit is contained in:
ArnabChatterjee20k
2026-04-06 17:14:12 +05:30
parent 6bc9adece8
commit d5fe5c34af
+3
View File
@@ -986,6 +986,9 @@ $server->onMessage(function (int $connection, string $message) use ($server, $re
// bulk validation + parsing before subscribing
$parsedPayloads = [];
foreach ($message['data'] as $payload) {
if (!\is_array($payload)) {
throw new Exception(Exception::REALTIME_MESSAGE_FORMAT_INVALID, 'Each subscribe payload must be an object.');
}
if (!array_key_exists('channels', $payload)) {
throw new Exception(Exception::REALTIME_MESSAGE_FORMAT_INVALID, 'channels is not present in payload.');
}