Merge pull request #58 from creative-commoners/pulls/2/php81

ENH PHP 8.1 compatibility
This commit is contained in:
Guy Sartorelli 2022-04-26 17:57:57 +12:00 committed by GitHub
commit 132d1257c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -142,8 +142,8 @@ class IFramePage extends Page
//whitelist allowed URL schemes
$allowed_schemes = array('http', 'https');
if ($matches = parse_url($this->IFrameURL)) {
if (isset($matches['scheme']) && !in_array($matches['scheme'], $allowed_schemes)) {
if ($matches = parse_url($this->IFrameURL ?? '')) {
if (isset($matches['scheme']) && !in_array($matches['scheme'], $allowed_schemes ?? [])) {
$result->addError(_t(__CLASS__ . '.VALIDATION_BANNEDURLSCHEME', "This URL scheme is not allowed."));
}
}

View File

@ -16,8 +16,8 @@ class IFramePageController extends PageController
if ($desiredProtocol && $currentProtocol !== $desiredProtocol) {
$enforcedLocation = preg_replace(
"#^${currentProtocol}#",
$desiredProtocol,
$this->AbsoluteLink()
$desiredProtocol ?? '',
$this->AbsoluteLink() ?? ''
);
return $this->redirect($enforcedLocation);
}