Commit cd76ab73 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Fix potential undefined index

parent 026a49d5
Pipeline #2070 passed with stages
in 2 minutes and 30 seconds
......@@ -22,7 +22,7 @@ $data = array();
try {
try {
$form = OnString::splitPathInfoToIdForm($_SERVER['PATH_INFO'], $restId, $restForm);
$form = OnString::splitPathInfoToIdForm($_SERVER['PATH_INFO'] ?? '', $restId, $restForm);
// get latest `ìd`
$id = end($restId);
......@@ -31,7 +31,7 @@ try {
$bodytext = TYPO3_RECORD_ID . '=' . $id . PHP_EOL;
$bodytext .= TYPO3_FORM . '=' . $form . PHP_EOL;
$method = $_SERVER['REQUEST_METHOD'];
$method = $_SERVER['REQUEST_METHOD'] ?? '';
switch ($method) {
case REQUEST_METHOD_GET:
$status = HTTP_200_OK;
......
......@@ -58,7 +58,8 @@ try {
if (isset($data[REPORT_SAVE])) {
// Redirect to previous page
header("Location: {$_SERVER['HTTP_REFERER']}");
$referer = $_SERVER['HTTP_REFERER'] ?? '';
header("Location: {$referer}");
}
$arr = $qfq->getForwardMode();
......
......@@ -75,7 +75,7 @@ class File {
}
// Throws an exception if content is too big - if content is bigger than 'post_max_size', the POST is lost together with the PHP Upload error message.
$size = isset($_SERVER['CONTENT_LENGTH']) ? $_SERVER['CONTENT_LENGTH'] : 0;
$size = $_SERVER['CONTENT_LENGTH'] ?? 0;
$this->checkMaxFileSize($size);
$statusUpload = $this->store->getVar($sipUpload, STORE_EXTRA, SANITIZE_ALLOW_ALL);
......
......@@ -742,8 +742,8 @@ class QuickFormQuery {
$formData = $_POST;
unset($formData[CLIENT_SIP]);
$formData = json_encode($formData, JSON_UNESCAPED_UNICODE);
$clientIp = $_SERVER[CLIENT_REMOTE_ADDRESS];
$userAgent = $_SERVER[CLIENT_HTTP_USER_AGENT];
$clientIp = $_SERVER[CLIENT_REMOTE_ADDRESS] ?? '';
$userAgent = $_SERVER[CLIENT_HTTP_USER_AGENT] ?? '';
$sipData = json_encode($this->store->getStore(STORE_SIP), JSON_UNESCAPED_UNICODE);
$formId = $this->formSpec[F_ID];
$recordId = $this->store->getVar(SIP_RECORD_ID, STORE_SIP);
......
......@@ -1092,7 +1092,7 @@ class Link {
case TOKEN_ACTION_DELETE_REPORT:
$nameUrlParam .= '&' . SIP_MODE_ANSWER . '=' . MODE_HTML;
// Encode '&' in url to preserve parameters (#4545) - need to decode on use.
$nameUrlParam .= '&' . SIP_TARGET_URL . '=' . str_replace('&', '--amp--', $_SERVER['REQUEST_URI']);
$nameUrlParam .= '&' . SIP_TARGET_URL . '=' . str_replace('&', '--amp--', $_SERVER['REQUEST_URI'] ?? '');
break;
case TOKEN_ACTION_DELETE_CLOSE:
// TODO: Implement for Form (primary Record wird geloescht)
......
......@@ -131,9 +131,9 @@ class Variables {
if (isset($_SERVER["REMOTE_ADDR"])) {
//TODO: Variablen sollten vom STORE_TYPO3 genommen werden
$arr["REMOTE_ADDR"] = $_SERVER["REMOTE_ADDR"];
$arr["HTTP_HOST"] = $_SERVER["HTTP_HOST"];
$arr["REQUEST_URI"] = $_SERVER["REQUEST_URI"];
$arr["REMOTE_ADDR"] = $_SERVER["REMOTE_ADDR"] ?? '';
$arr["HTTP_HOST"] = $_SERVER["HTTP_HOST"] ?? '';
$arr["REQUEST_URI"] = $_SERVER["REQUEST_URI"] ?? '';
$protocol = 'http';
if (isset($_SERVER['HTTPS'])) {
......
......@@ -80,7 +80,7 @@ class Session
throw new \CodeException('Missing _SERVER[SCRIPT_NAME]', ERROR_SESSION_BROKEN_SCRIPT_PATH);
}
$path = $_SERVER['SCRIPT_NAME'];
$path = $_SERVER['SCRIPT_NAME'] ?? '';
$pos = strrpos($path, '/');
if ($pos === false) {
......
......@@ -263,16 +263,16 @@ class Store {
} else {
// If we are called through AJAX API (e.g. api/save.php), there is no TYPO3 environment.
$pos = strpos($_SERVER['SCRIPT_FILENAME'], $relExtDir);
$pos = strpos($_SERVER['SCRIPT_FILENAME'] ?? '', $relExtDir);
if ($pos === false && isset($GLOBALS['TYPO3_LOADED_EXT'][EXT_KEY]['ext_localconf.php'])) {
// Typo3 extension: probably index.php
$config[SYSTEM_EXT_PATH] = dirname($GLOBALS['TYPO3_LOADED_EXT'][EXT_KEY]['ext_localconf.php']);
$config[SYSTEM_SITE_PATH] = dirname($_SERVER['SCRIPT_FILENAME']);
$config[SYSTEM_SITE_PATH] = dirname($_SERVER['SCRIPT_FILENAME'] ?? '');
} else {
// API
$config[SYSTEM_EXT_PATH] = substr($_SERVER['SCRIPT_FILENAME'], 0, $pos + strlen($relExtDir));
$config[SYSTEM_SITE_PATH] = substr($_SERVER['SCRIPT_FILENAME'], 0, $pos);
$config[SYSTEM_EXT_PATH] = substr($_SERVER['SCRIPT_FILENAME'] ?? '', 0, $pos + strlen($relExtDir));
$config[SYSTEM_SITE_PATH] = substr($_SERVER['SCRIPT_FILENAME'] ?? '', 0, $pos);
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment