make encoding validation on message enter

This commit is contained in:
ghost 2024-05-01 16:56:22 +03:00
parent 5427b135d5
commit a4189b0a1f

View File

@ -194,17 +194,6 @@ class Ratchet implements MessageComponentInterface
);
}
// Check message encoding valid
else if (!mb_check_encoding($connection->message, 'UTF-8'))
{
$connection->send(
implode(
PHP_EOL,
$config->response->submit->failure->encoding
) . PHP_EOL
);
}
// Max length already checked on input, begin message save
else
{
@ -277,6 +266,19 @@ class Ratchet implements MessageComponentInterface
// Complete message by new line sent
$connection->message .= $request . PHP_EOL;
// Check message encoding valid
if (!mb_check_encoding($connection->message, 'UTF-8'))
{
$connection->send(
implode(
PHP_EOL,
$config->response->submit->failure->encoding
) . PHP_EOL
);
$connection->close();
}
// Check total message length limit allowed by KevaCoin protocol
if (mb_strlen($connection->message) > 3074)
{