Sign: apply a very stupid limit on text size

this is necessary because of the epidemic of server attacks going around lately.
This commit is contained in:
Dylan K. Taylor 2019-04-14 19:30:28 +01:00
parent 4c268acc00
commit 389e7767d1

View File

@ -36,6 +36,7 @@ use function implode;
use function mb_check_encoding;
use function mb_scrub;
use function sprintf;
use function strlen;
class Sign extends Spawnable{
public const TAG_TEXT_BLOB = "Text";
@ -151,6 +152,14 @@ class Sign extends Spawnable{
}else{
return false;
}
$size = 0;
foreach($lines as $line){
$size += strlen($line);
}
if($size > 1000){
//trigger kick + IP ban - TODO: on 4.0 this will require a better fix
throw new \UnexpectedValueException($player->getName() . " tried to write $size bytes of text onto a sign (bigger than max 1000)");
}
$removeFormat = $player->getRemoveFormat();