Skip to content

Commit

Permalink
fixing php 8.1 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarholt committed Oct 4, 2022
1 parent 85a7606 commit 1ece7f3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/filters/MisDirectionRequestProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions src/objects/LinkMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -409,7 +409,7 @@ public function getLinkHost() {

public function getLinkSummary() {

return ($link = $this->getLink()) ? trim($link, ' ?/') : '-';
return ($link = $this->getLink()) ? trim($link ?? '', ' ?/') : '-';
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/services/MisdirectionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class MisdirectionService {

public static function unify_URL($URL) {

return strtolower(trim($URL, ' ?/'));
return strtolower(trim($URL ?? '', ' ?/'));
}

/**
Expand All @@ -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);
}

Expand Down

0 comments on commit 1ece7f3

Please sign in to comment.