- Fixed a missing variable bug
This commit is contained in:
parent
4834404575
commit
6b1be4d245
18
src/File.php
18
src/File.php
@ -40,4 +40,22 @@ class File
|
|||||||
|
|
||||||
return array_reverse($text);
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -58,10 +58,9 @@ class Kernel
|
|||||||
if (($keys = getenv('KEYS')) && ($auth = $_SERVER["HTTP_X_DEV_AUTH"] ?? null) && in_array($auth, explode(',', $keys))) {
|
if (($keys = getenv('KEYS')) && ($auth = $_SERVER["HTTP_X_DEV_AUTH"] ?? null) && in_array($auth, explode(',', $keys))) {
|
||||||
unset($_SERVER["HTTP_X_DEV_AUTH"]);
|
unset($_SERVER["HTTP_X_DEV_AUTH"]);
|
||||||
|
|
||||||
unset($_ENV[$name], $_SERVER[$name]);
|
unset($_ENV['KEYS'], $_SERVER['KEYS']);
|
||||||
putenv("KEYS=");
|
putenv("KEYS=");
|
||||||
|
|
||||||
|
|
||||||
foreach(['APP_ENV', 'DEBUG',] as $env) {
|
foreach(['APP_ENV', 'DEBUG',] as $env) {
|
||||||
if (null !== $value = $_SERVER["HTTP_X_$env"] ?? null) {
|
if (null !== $value = $_SERVER["HTTP_X_$env"] ?? null) {
|
||||||
static::putenv($env, $value);
|
static::putenv($env, $value);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user