From b919a7e829228b21a83c8a990d0b49116ba9652c Mon Sep 17 00:00:00 2001 From: Alex Cabal Date: Fri, 1 Sep 2023 12:42:25 -0500 Subject: [PATCH] Fix some validation errors --- lib/HttpInput.php | 2 +- lib/PollVote.php | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/HttpInput.php b/lib/HttpInput.php index 60f3b48d..ece627a9 100644 --- a/lib/HttpInput.php +++ b/lib/HttpInput.php @@ -22,7 +22,7 @@ class HttpInput{ } public static function RequestType(): int{ - return preg_match('/\btext\/html\b/ius', $_SERVER['HTTP_ACCEPT']) ? WEB : REST; + return preg_match('/\btext\/html\b/ius', $_SERVER['HTTP_ACCEPT'] ?? '') ? WEB : REST; } public static function Str(string $type, string $variable, bool $allowEmptyString = true, string $default = null): ?string{ diff --git a/lib/PollVote.php b/lib/PollVote.php index 3105f7a2..d34ddfcf 100644 --- a/lib/PollVote.php +++ b/lib/PollVote.php @@ -46,10 +46,16 @@ class PollVote extends PropertiesBase{ if($this->PollItem === null){ $error->Add(new Exceptions\InvalidPollException()); } - } - - if(!$this->PollItem->Poll->IsActive()){ - $error->Add(new Exceptions\PollClosedException()); + else{ + if($this->PollItem->Poll === null){ + $error->Add(new Exceptions\InvalidPollException()); + } + else{ + if(!$this->PollItem->Poll->IsActive()){ + $error->Add(new Exceptions\PollClosedException()); + } + } + } } if(!$error->HasExceptions){