diff --git a/src/Control/CLIRequestBuilder.php b/src/Control/CLIRequestBuilder.php
index a5ec492e9ec..006dc7ab6d2 100644
--- a/src/Control/CLIRequestBuilder.php
+++ b/src/Control/CLIRequestBuilder.php
@@ -46,13 +46,13 @@ public static function cleanEnvironment(array $variables)
* fourth => val
*/
if (isset($variables['_SERVER']['argv'][2])) {
- $args = array_slice($variables['_SERVER']['argv'], 2);
+ $args = array_slice($variables['_SERVER']['argv'] ?? [], 2);
foreach ($args as $arg) {
- if (strpos($arg, '=') == false) {
+ if (strpos($arg ?? '', '=') == false) {
$variables['_GET']['args'][] = $arg;
} else {
$newItems = [];
- parse_str((substr($arg, 0, 2) == '--') ? substr($arg, 2) : $arg, $newItems);
+ parse_str((substr($arg ?? '', 0, 2) == '--') ? substr($arg, 2) : $arg, $newItems);
$variables['_GET'] = array_merge($variables['_GET'], $newItems);
}
}
@@ -79,7 +79,7 @@ public static function createFromVariables(array $variables, $input, $url = null
{
$request = parent::createFromVariables($variables, $input, $url);
// unset scheme so that SS_BASE_URL can provide `is_https` information if required
- $scheme = parse_url(Environment::getEnv('SS_BASE_URL'), PHP_URL_SCHEME);
+ $scheme = parse_url(Environment::getEnv('SS_BASE_URL') ?? '', PHP_URL_SCHEME);
if ($scheme) {
$request->setScheme($scheme);
}
diff --git a/src/Control/ContentNegotiator.php b/src/Control/ContentNegotiator.php
index fa8c8ff5a51..3e17d06d4f2 100644
--- a/src/Control/ContentNegotiator.php
+++ b/src/Control/ContentNegotiator.php
@@ -79,8 +79,8 @@ public static function enabled_for($response)
// Disable content negotiation for other content types
if ($contentType
- && substr($contentType, 0, 9) != 'text/html'
- && substr($contentType, 0, 21) != 'application/xhtml+xml'
+ && substr($contentType ?? '', 0, 9) != 'text/html'
+ && substr($contentType ?? '', 0, 21) != 'application/xhtml+xml'
) {
return false;
}
@@ -88,7 +88,7 @@ public static function enabled_for($response)
if (ContentNegotiator::getEnabled()) {
return true;
} else {
- return (substr($response->getBody(), 0, 5) == '<' . '?xml');
+ return (substr($response->getBody() ?? '', 0, 5) == '<' . '?xml');
}
}
@@ -136,12 +136,12 @@ public static function process(HTTPResponse $response)
} else {
// The W3C validator doesn't send an HTTP_ACCEPT header, but it can support xhtml. We put this
// special case in here so that designers don't get worried that their templates are HTML4.
- if (isset($_SERVER['HTTP_USER_AGENT']) && substr($_SERVER['HTTP_USER_AGENT'], 0, 14) == 'W3C_Validator/') {
+ if (isset($_SERVER['HTTP_USER_AGENT']) && substr($_SERVER['HTTP_USER_AGENT'] ?? '', 0, 14) == 'W3C_Validator/') {
$chosenFormat = "xhtml";
} else {
foreach ($mimes as $format => $mime) {
- $regExp = '/' . str_replace(['+', '/'], ['\+', '\/'], $mime) . '(;q=(\d+\.\d+))?/i';
- if (isset($_SERVER['HTTP_ACCEPT']) && preg_match($regExp, $_SERVER['HTTP_ACCEPT'], $matches)) {
+ $regExp = '/' . str_replace(['+', '/'], ['\+', '\/'], $mime ?? '') . '(;q=(\d+\.\d+))?/i';
+ if (isset($_SERVER['HTTP_ACCEPT']) && preg_match($regExp ?? '', $_SERVER['HTTP_ACCEPT'] ?? '', $matches)) {
$preference = isset($matches[2]) ? $matches[2] : 1;
if (!isset($q[$preference])) {
$q[$preference] = $format;
@@ -189,17 +189,17 @@ public function xhtml(HTTPResponse $response)
$content = preg_replace(
'//',
'',
- $content
+ $content ?? ''
);
- $content = str_replace(' ', ' ', $content);
- $content = str_replace('
', '
', $content);
- $content = str_replace('
', '
', $content);
- $content = preg_replace('#(]*[^/>])>#i', '\\1/>', $content);
- $content = preg_replace('#(]*[^/>])>#i', '\\1/>', $content);
- $content = preg_replace('#(]*[^/>])>#i', '\\1/>', $content);
- $content = preg_replace("#(\