mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-09 03:06:55 +00:00
BanEntry: work around stupid bug in ext/date
https://bugs.php.net/bug.php?id=75992 When plugins do time-limited bans and users enter stupid time values, a shitty bug in ext/date gets triggered, but only when reading the ban entries from disk. DateTime->format() is able to produce formatted strings which have more than 4 digits in the year, which are then considered invalid. This works around it by trying to parse a formatted version on the fly to ensure that it is valid. This also cleans up and improves ban list loading and handling.
This commit is contained in:
@ -147,9 +147,15 @@ class BanList{
|
||||
if(is_resource($fp)){
|
||||
while(($line = fgets($fp)) !== false){
|
||||
if($line{0} !== "#"){
|
||||
$entry = BanEntry::fromString($line);
|
||||
if($entry instanceof BanEntry){
|
||||
$this->list[$entry->getName()] = $entry;
|
||||
try{
|
||||
$entry = BanEntry::fromString($line);
|
||||
if($entry instanceof BanEntry){
|
||||
$this->list[$entry->getName()] = $entry;
|
||||
}
|
||||
}catch(\Throwable $e){
|
||||
$logger = MainLogger::getLogger();
|
||||
$logger->critical("Failed to parse ban entry from string \"$line\": " . $e->getMessage());
|
||||
$logger->logException($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user