diff --git a/config/example.json b/config/example.json index f0220bb..2dd6f28 100644 --- a/config/example.json +++ b/config/example.json @@ -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", diff --git a/src/Server/Ratchet.php b/src/Server/Ratchet.php index 911bc60..26b6f13 100644 --- a/src/Server/Ratchet.php +++ b/src/Server/Ratchet.php @@ -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 {