Browse Source

add message encoding validation

main
ghost 7 months ago
parent
commit
5427b135d5
  1. 4
      config/example.json
  2. 11
      src/Server/Ratchet.php

4
config/example.json

@ -109,6 +109,10 @@ @@ -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",

11
src/Server/Ratchet.php

@ -194,6 +194,17 @@ class Ratchet implements MessageComponentInterface @@ -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
{

Loading…
Cancel
Save