From 1ece7f36bb3c635fb06fb0fc7a02ed0cbbb956aa Mon Sep 17 00:00:00 2001 From: Oscar Date: Wed, 5 Oct 2022 09:17:23 +1300 Subject: [PATCH] fixing php 8.1 errors --- src/filters/MisDirectionRequestProcessor.php | 2 +- src/objects/LinkMapping.php | 6 +++--- src/services/MisdirectionService.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/filters/MisDirectionRequestProcessor.php b/src/filters/MisDirectionRequestProcessor.php index c21e2eb..524916c 100644 --- a/src/filters/MisDirectionRequestProcessor.php +++ b/src/filters/MisDirectionRequestProcessor.php @@ -66,7 +66,7 @@ public function process(HTTPRequest $request, callable $delegate) // Retrieve the specific director rules. if(($position = strpos($segment, '$')) !== false) { - $segment = rtrim(substr($segment, 0, $position), '/'); + $segment = rtrim(substr($segment ?? '', 0, $position), '/'); } // Determine if the current request matches a specific director rule. diff --git a/src/objects/LinkMapping.php b/src/objects/LinkMapping.php index 629aed3..b4ef2ec 100644 --- a/src/objects/LinkMapping.php +++ b/src/objects/LinkMapping.php @@ -302,7 +302,7 @@ public function onBeforeWrite() { parent::onBeforeWrite(); $this->MappedLink = MisdirectionService::unify_URL($this->MappedLink); - $this->RedirectLink = trim($this->RedirectLink, ' ?/'); + $this->RedirectLink = trim($this->RedirectLink ?? '', ' ?/'); $this->HostnameRestriction = MisdirectionService::unify_URL($this->HostnameRestriction); } @@ -333,7 +333,7 @@ public function getLink() { // This is to support multiple sites, where the absolute page URLs are treated as relative. - return MisdirectionService::is_external_URL($link) ? ltrim($link, '/') : $link; + return MisdirectionService::is_external_URL($link) ? ltrim($link ?? '', '/') : $link; } } else { @@ -409,7 +409,7 @@ public function getLinkHost() { public function getLinkSummary() { - return ($link = $this->getLink()) ? trim($link, ' ?/') : '-'; + return ($link = $this->getLink()) ? trim($link ?? '', ' ?/') : '-'; } /** diff --git a/src/services/MisdirectionService.php b/src/services/MisdirectionService.php index 19dd015..4e9d85b 100644 --- a/src/services/MisdirectionService.php +++ b/src/services/MisdirectionService.php @@ -29,7 +29,7 @@ class MisdirectionService { public static function unify_URL($URL) { - return strtolower(trim($URL, ' ?/')); + return strtolower(trim($URL ?? '', ' ?/')); } /** @@ -41,7 +41,7 @@ public static function unify_URL($URL) { public static function is_external_URL($URL) { - $URL = trim($URL, '/?!"#$%&\'()*+,-.@:;<=>[\\]^_`{|}~'); + $URL = trim($URL ?? '', '/?!"#$%&\'()*+,-.@:;<=>[\\]^_`{|}~'); return preg_match('%^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@|\d{1,3}(?:\.\d{1,3}){3}|(?:(?:[a-z\d\x{00a1}-\x{ffff}]+-?)*[a-z\d\x{00a1}-\x{ffff}]+)(?:\.(?:[a-z\d\x{00a1}-\x{ffff}]+-?)*[a-z\d\x{00a1}-\x{ffff}]+)*(?:\.[a-z\x{00a1}-\x{ffff}]{2,6}))(?::\d+)?(?:[^\s]*)?$%iu', $URL); }