mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-13 05:15:13 +00:00
InGamePacketHandler: fixed inconsistent handling of invalid data in BlockActorDataPacket
This commit is contained in:
parent
70dd9c7371
commit
0c250a2ef0
@ -113,9 +113,9 @@ use pocketmine\utils\TextFormat;
|
|||||||
use pocketmine\utils\Utils;
|
use pocketmine\utils\Utils;
|
||||||
use pocketmine\world\format\Chunk;
|
use pocketmine\world\format\Chunk;
|
||||||
use function array_push;
|
use function array_push;
|
||||||
use function base64_encode;
|
|
||||||
use function count;
|
use function count;
|
||||||
use function fmod;
|
use function fmod;
|
||||||
|
use function get_debug_type;
|
||||||
use function implode;
|
use function implode;
|
||||||
use function in_array;
|
use function in_array;
|
||||||
use function is_bool;
|
use function is_bool;
|
||||||
@ -748,27 +748,32 @@ class InGamePacketHandler extends PacketHandler{
|
|||||||
if(!($nbt instanceof CompoundTag)) throw new AssumptionFailedError("PHPStan should ensure this is a CompoundTag"); //for phpstorm's benefit
|
if(!($nbt instanceof CompoundTag)) throw new AssumptionFailedError("PHPStan should ensure this is a CompoundTag"); //for phpstorm's benefit
|
||||||
|
|
||||||
if($block instanceof BaseSign){
|
if($block instanceof BaseSign){
|
||||||
if(($textBlobTag = $nbt->getCompoundTag(Sign::TAG_FRONT_TEXT)?->getTag(Sign::TAG_TEXT_BLOB)) instanceof StringTag){
|
$frontTextTag = $nbt->getTag(Sign::TAG_FRONT_TEXT);
|
||||||
try{
|
if(!$frontTextTag instanceof CompoundTag){
|
||||||
$text = SignText::fromBlob($textBlobTag->getValue());
|
throw new PacketHandlingException("Invalid tag type " . get_debug_type($frontTextTag) . " for tag \"" . Sign::TAG_FRONT_TEXT . "\" in sign update data");
|
||||||
}catch(\InvalidArgumentException $e){
|
}
|
||||||
throw PacketHandlingException::wrap($e, "Invalid sign text update");
|
$textBlobTag = $frontTextTag->getTag(Sign::TAG_TEXT_BLOB);
|
||||||
}
|
if(!$textBlobTag instanceof StringTag){
|
||||||
|
throw new PacketHandlingException("Invalid tag type " . get_debug_type($textBlobTag) . " for tag \"" . Sign::TAG_TEXT_BLOB . "\" in sign update data");
|
||||||
try{
|
|
||||||
if(!$block->updateText($this->player, $text)){
|
|
||||||
foreach($this->player->getWorld()->createBlockUpdatePackets([$pos]) as $updatePacket){
|
|
||||||
$this->session->sendDataPacket($updatePacket);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}catch(\UnexpectedValueException $e){
|
|
||||||
throw PacketHandlingException::wrap($e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->session->getLogger()->debug("Invalid sign update data: " . base64_encode($packet->nbt->getEncodedNbt()));
|
try{
|
||||||
|
$text = SignText::fromBlob($textBlobTag->getValue());
|
||||||
|
}catch(\InvalidArgumentException $e){
|
||||||
|
throw PacketHandlingException::wrap($e, "Invalid sign text update");
|
||||||
|
}
|
||||||
|
|
||||||
|
try{
|
||||||
|
if(!$block->updateText($this->player, $text)){
|
||||||
|
foreach($this->player->getWorld()->createBlockUpdatePackets([$pos]) as $updatePacket){
|
||||||
|
$this->session->sendDataPacket($updatePacket);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch(\UnexpectedValueException $e){
|
||||||
|
throw PacketHandlingException::wrap($e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user