From a3ca2ffcfb1fba28c8d2e8e34776d104ab155813 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Thu, 4 Oct 2012 01:20:48 +0200 Subject: [PATCH] Also return false for validation if the path is shorter than the root path --- snippets/php/path_root_validation.php | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/snippets/php/path_root_validation.php b/snippets/php/path_root_validation.php index 315e113..d3c2533 100644 --- a/snippets/php/path_root_validation.php +++ b/snippets/php/path_root_validation.php @@ -21,18 +21,25 @@ class PathValidator if($root_path != null) { - $root_stack = explode("/", $root_path); - $path_stack = explode("/", $this->path); - - for($i = 0; $i < count($root_stack); $i++) + if($this->RelativeDepth($root) >= 0) { - if($root_stack[$i] != $path_stack[$i]) + $root_stack = explode("/", $root_path); + $path_stack = explode("/", $this->path); + + for($i = 0; $i < count($root_stack); $i++) { - return false; + if($root_stack[$i] != $path_stack[$i]) + { + return false; + } } + + return true; + } + else + { + return false; } - - return true; } else {