From a4189b0a1fc0c5a118466cd6bb53f7c1b1bfb0bf Mon Sep 17 00:00:00 2001 From: ghost Date: Wed, 1 May 2024 16:56:22 +0300 Subject: [PATCH] make encoding validation on message enter --- src/Server/Ratchet.php | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/Server/Ratchet.php b/src/Server/Ratchet.php index 26b6f13..a1757c6 100644 --- a/src/Server/Ratchet.php +++ b/src/Server/Ratchet.php @@ -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) {