mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-18 04:00:29 +00:00
add some UTF-8 validation
This commit is contained in:
@@ -45,6 +45,7 @@ use pocketmine\nbt\tag\StringTag;
|
||||
use pocketmine\nbt\TreeRoot;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\utils\Binary;
|
||||
use pocketmine\utils\Utils;
|
||||
use function base64_decode;
|
||||
use function base64_encode;
|
||||
use function get_class;
|
||||
@@ -163,7 +164,7 @@ class Item implements \JsonSerializable{
|
||||
* @return $this
|
||||
*/
|
||||
public function setCustomName(string $name) : Item{
|
||||
//TODO: encoding might need to be checked here
|
||||
Utils::checkUTF8($name);
|
||||
$this->customName = $name;
|
||||
return $this;
|
||||
}
|
||||
@@ -193,6 +194,7 @@ class Item implements \JsonSerializable{
|
||||
if(!is_string($line)){
|
||||
throw new \TypeError("Expected string[], but found " . gettype($line) . " in given array");
|
||||
}
|
||||
Utils::checkUTF8($line);
|
||||
}
|
||||
$this->lore = $lines;
|
||||
return $this;
|
||||
|
@@ -23,6 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\utils\Utils;
|
||||
|
||||
class WritableBookPage{
|
||||
|
||||
/** @var string */
|
||||
@@ -31,7 +33,8 @@ class WritableBookPage{
|
||||
private $photoName;
|
||||
|
||||
public function __construct(string $text, string $photoName = ""){
|
||||
//TODO: data validation, encoding checks
|
||||
//TODO: data validation
|
||||
Utils::checkUTF8($text);
|
||||
$this->text = $text;
|
||||
$this->photoName = $photoName;
|
||||
}
|
||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\utils\Utils;
|
||||
|
||||
class WrittenBook extends WritableBookBase{
|
||||
|
||||
@@ -92,6 +93,7 @@ class WrittenBook extends WritableBookBase{
|
||||
* @return $this
|
||||
*/
|
||||
public function setAuthor(string $authorName) : self{
|
||||
Utils::checkUTF8($authorName);
|
||||
$this->author = $authorName;
|
||||
return $this;
|
||||
}
|
||||
@@ -113,6 +115,7 @@ class WrittenBook extends WritableBookBase{
|
||||
* @return $this
|
||||
*/
|
||||
public function setTitle(string $title) : self{
|
||||
Utils::checkUTF8($title);
|
||||
$this->title = $title;
|
||||
return $this;
|
||||
}
|
||||
|
Reference in New Issue
Block a user