From 9848c096e69ba73b2cd8bc35a8c3f74e23432fb2 Mon Sep 17 00:00:00 2001 From: Wruczek Date: Tue, 6 Oct 2020 04:26:04 +0200 Subject: [PATCH] bans.php - dont pass null into Utils::escape --- src/bans.php | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/bans.php b/src/bans.php index e77777a..b5339b4 100644 --- a/src/bans.php +++ b/src/bans.php @@ -33,18 +33,22 @@ if ($banlist !== null) { // will just show the UID, IP or MyTSID $target = "(unknown)"; - $lastNickname = Utils::escape($ban["lastnickname"]); + $lastNickname = null; $filter = ""; $abbreviation = null; + if ($ban["lastnickname"] !== null) { + $lastNickname = Utils::escape($ban["lastnickname"]); + } + if ($ban["ip"]) { - $ip = str_replace("\\", "", (string)$ban["ip"]); + $ip = str_replace("\\", "", (string) $ban["ip"]); try { $ip = Utils::censorIpAddress($ip); } catch (\Exception $e) {} - if ($lastNickname) { + if ($lastNickname !== null) { $abbreviation = [$ip, "IP"]; } else { $target = $ip; @@ -52,12 +56,12 @@ if ($banlist !== null) { if ($ip === Utils::getClientIp()) { $ipbanned = [ - "invoker" => (string)$ban["invokername"], - "reason" => (string)$ban["reason"] + "invoker" => (string) $ban["invokername"], + "reason" => (string) $ban["reason"] ]; } } else if ($ban["uid"]) { - if ($lastNickname) { + if ($lastNickname !== null) { $abbreviation = [$ban["uid"], "UID"]; } else { $target = new Html("" . $ban["uid"] . ""); @@ -65,7 +69,7 @@ if ($banlist !== null) { } else if ($ban["name"]) { $target = $ban["name"]; } else if (!empty($ban["mytsid"])) { // empty, older TS servers dont have MYTS bans, so the key might not exist - if ($lastNickname) { + if ($lastNickname !== null) { $abbreviation = [$ban["mytsid"], "MyTSID"]; } else { $target = new Html("" . $ban["mytsid"] . ""); @@ -83,8 +87,8 @@ if ($banlist !== null) { $data[] = [ "filter" => $filter, "target" => $target, - "reason" => (string)$ban["reason"], - "invoker" => (string)$ban["invokername"], + "reason" => (string) $ban["reason"], + "invoker" => (string) $ban["invokername"], "created" => $ban["created"], "duration" => $ban["duration"] ];