add absolute path validation

This commit is contained in:
yggverse 2024-04-27 01:38:54 +03:00
parent 2cc63b3a36
commit 8ee31bdbf9

View File

@ -38,6 +38,15 @@ foreach ((array) $argv as $item)
DIRECTORY_SEPARATOR DIRECTORY_SEPARATOR
) . DIRECTORY_SEPARATOR; ) . DIRECTORY_SEPARATOR;
if (!str_starts_with($path, DIRECTORY_SEPARATOR))
{
print(
_('absolute path required')
) . PHP_EOL;
exit;
}
if (!is_dir($path) || !is_readable($path)) if (!is_dir($path) || !is_readable($path))
{ {
print( print(
@ -70,6 +79,15 @@ foreach ((array) $argv as $item)
DIRECTORY_SEPARATOR DIRECTORY_SEPARATOR
) . DIRECTORY_SEPARATOR; ) . DIRECTORY_SEPARATOR;
if (!str_starts_with($fail, DIRECTORY_SEPARATOR))
{
print(
_('absolute path required')
) . PHP_EOL;
exit;
}
if (!is_file($fail) || !is_readable($fail)) if (!is_file($fail) || !is_readable($fail))
{ {
print( print(