- Fixed a missing variable bug

This commit is contained in:
Dave M. 2026-07-07 12:42:25 +00:00
parent 4834404575
commit 6b1be4d245
2 changed files with 24 additions and 7 deletions

View File

@ -40,4 +40,22 @@ class File
return array_reverse($text);
}
public static function sanitizeFilePath($path) : string
{
// Remove null bytes
$path = str_replace("\0", "", $path);
$path = str_replace([ "\\", "/" ], DIRECTORY_SEPARATOR, $path);
$path = preg_replace('#' . DIRECTORY_SEPARATOR . '+#', DIRECTORY_SEPARATOR, $path);
// Remove . and .. directory traversal attempts
$path = preg_replace('#\.{1,2}/#', '', $path);
$path = trim($path, '/\\');
return $path;
}
}

View File

@ -58,10 +58,9 @@ class Kernel
if (($keys = getenv('KEYS')) && ($auth = $_SERVER["HTTP_X_DEV_AUTH"] ?? null) && in_array($auth, explode(',', $keys))) {
unset($_SERVER["HTTP_X_DEV_AUTH"]);
unset($_ENV[$name], $_SERVER[$name]);
unset($_ENV['KEYS'], $_SERVER['KEYS']);
putenv("KEYS=");
foreach(['APP_ENV', 'DEBUG',] as $env) {
if (null !== $value = $_SERVER["HTTP_X_$env"] ?? null) {
static::putenv($env, $value);