From 8ee31bdbf915d52fc8c27073dda81d33b7723d23 Mon Sep 17 00:00:00 2001 From: yggverse Date: Sat, 27 Apr 2024 01:38:54 +0300 Subject: [PATCH] add absolute path validation --- src/nex.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/nex.php b/src/nex.php index 416199c..f040ab3 100644 --- a/src/nex.php +++ b/src/nex.php @@ -38,6 +38,15 @@ foreach ((array) $argv as $item) 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)) { print( @@ -70,6 +79,15 @@ foreach ((array) $argv as $item) 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)) { print(