add message encoding validation

This commit is contained in:
ghost 2024-05-01 16:38:06 +03:00
parent 67c3c24744
commit 5427b135d5
2 changed files with 15 additions and 0 deletions

View File

@ -109,6 +109,10 @@
[
"\u001b[31mMessage could not be empty!\u001b[0m"
],
"encoding":
[
"\u001b[31mInvalid message encoding!\u001b[0m"
],
"internal":
[
"\u001b[31mSomething went wrong, please make your feedback!\u001b[0m",

View File

@ -194,6 +194,17 @@ 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
{