add some UTF-8 validation

This commit is contained in:
Dylan K. Taylor
2019-08-01 19:51:31 +01:00
parent 399ef13069
commit 135a2f520c
5 changed files with 19 additions and 5 deletions

View File

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace pocketmine\block\utils;
use pocketmine\utils\Utils;
use function array_fill;
use function array_pad;
use function array_slice;
@ -118,9 +119,7 @@ class SignText{
*/
public function setLine(int $index, string $line) : void{
$this->checkLineIndex($index);
if(!mb_check_encoding($line, 'UTF-8')){
throw new \InvalidArgumentException("Line must be valid UTF-8 text");
}
Utils::checkUTF8($line);
if(strpos($line, "\n") !== false){
throw new \InvalidArgumentException("Line must not contain newlines");
}