mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 20:28:31 +00:00
Player: Be more explicit about not parsing chat messages when messageCounter is zero
the length check technically accounts for this, but future readers might not realize this
This commit is contained in:
parent
1591881bf2
commit
38d75f3aab
@ -1377,6 +1377,11 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
|||||||
public function chat(string $message) : bool{
|
public function chat(string $message) : bool{
|
||||||
$this->removeCurrentWindow();
|
$this->removeCurrentWindow();
|
||||||
|
|
||||||
|
if($this->messageCounter <= 0){
|
||||||
|
//the check below would take care of this (0 * (maxlen + 1) = 0), but it's better be explicit
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//Fast length check, to make sure we don't get hung trying to explode MBs of string ...
|
//Fast length check, to make sure we don't get hung trying to explode MBs of string ...
|
||||||
$maxTotalLength = $this->messageCounter * (self::MAX_CHAT_BYTE_LENGTH + 1);
|
$maxTotalLength = $this->messageCounter * (self::MAX_CHAT_BYTE_LENGTH + 1);
|
||||||
if(strlen($message) > $maxTotalLength){
|
if(strlen($message) > $maxTotalLength){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user