Skip to content

Commit

Permalink
Fix banlist crash when | is entered in any /ban arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
dktapps committed Oct 17, 2016
1 parent f3e35bb commit d53810c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/pocketmine/permission/BanEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

namespace pocketmine\permission;

use pocketmine\utils\MainLogger;

class BanEntry{
public static $format = "Y-m-d H:i:s O";

Expand Down Expand Up @@ -109,7 +111,12 @@ public static function fromString($str){
$str = explode("|", trim($str));
$entry = new BanEntry(trim(array_shift($str)));
if(count($str) > 0){
$entry->setCreated(\DateTime::createFromFormat(self::$format, array_shift($str)));
$datetime = \DateTime::createFromFormat(self::$format, array_shift($str));
if(!($datetime instanceof \DateTime)){
MainLogger::getLogger()->alert("Error parsing date for BanEntry for player \"" . $entry->getName() . "\", the format may be invalid!");
return $entry;
}
$entry->setCreated($datetime);
if(count($str) > 0){
$entry->setSource(trim(array_shift($str)));
if(count($str) > 0){
Expand Down

0 comments on commit d53810c

Please sign in to comment.