From f7896f46a5d93ce9119db71e75d77cc1af5bc139 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sat, 24 May 2014 17:57:01 +0200 Subject: [PATCH] [ticket/12589] Search directly in $directory if it's an absolute sub-path PHPBB3-12589 --- phpBB/phpbb/extension/finder.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/phpBB/phpbb/extension/finder.php b/phpBB/phpbb/extension/finder.php index 6cc6e1808a..09c4f6d3e0 100644 --- a/phpBB/phpbb/extension/finder.php +++ b/phpBB/phpbb/extension/finder.php @@ -463,6 +463,7 @@ class finder } else if ($directory && $directory[0] === '/') { + $path .= substr($directory, 1); $directory_pattern = '^' . preg_quote(str_replace('/', DIRECTORY_SEPARATOR, $directory) . DIRECTORY_SEPARATOR, '#'); } else @@ -494,7 +495,11 @@ class finder if ($is_dir) { $relative_path = $iterator->getInnerIterator()->getSubPath() . DIRECTORY_SEPARATOR . basename($filename) . DIRECTORY_SEPARATOR; - if ($relative_path[0] !== DIRECTORY_SEPARATOR) + if ($directory && $directory[0] === '/') + { + $relative_path = str_replace('/', DIRECTORY_SEPARATOR, $directory) . DIRECTORY_SEPARATOR . $relative_path; + } + else if ($relative_path[0] !== DIRECTORY_SEPARATOR) { $relative_path = DIRECTORY_SEPARATOR . $relative_path; } @@ -502,6 +507,14 @@ class finder else { $relative_path = DIRECTORY_SEPARATOR . $iterator->getInnerIterator()->getSubPathname(); + if ($directory && $directory[0] === '/') + { + $relative_path = str_replace('/', DIRECTORY_SEPARATOR, $directory) . DIRECTORY_SEPARATOR . $relative_path; + } + else + { + $relative_path = DIRECTORY_SEPARATOR . $relative_path; + } } if ((!$suffix || substr($relative_path, -strlen($suffix)) === $suffix) &&