From 733f4e2530f6248702e2ab33ce3548701244209f Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 26 Dec 2022 14:42:49 +0100 Subject: [PATCH] [ticket/16955] Wrap RecursiveDirectoryIteratorr calls for dot prefix filter PHPBB3-16955 --- .../recursive_dot_prefix_filter_iterator.php | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/phpBB/phpbb/iterator/recursive_dot_prefix_filter_iterator.php b/phpBB/phpbb/iterator/recursive_dot_prefix_filter_iterator.php index 4549e03e8e..08f5bde262 100644 --- a/phpBB/phpbb/iterator/recursive_dot_prefix_filter_iterator.php +++ b/phpBB/phpbb/iterator/recursive_dot_prefix_filter_iterator.php @@ -22,9 +22,38 @@ namespace phpbb\iterator; */ class recursive_dot_prefix_filter_iterator extends \RecursiveFilterIterator { - public function accept() + /** + * Check whether the current element of the iterator is acceptable + * + * @return bool + */ + public function accept(): bool { $filename = $this->current()->getFilename(); return $filename[0] !== '.' || !$this->current()->isDir(); } + + /** + * Get sub path + * + * @return string + */ + public function getSubPath(): string + { + $directory_iterator = $this->getInnerIterator(); + assert($directory_iterator instanceof \RecursiveDirectoryIterator); + return $directory_iterator->getSubPath(); + } + + /** + * Get sub path and name + * + * @return string + */ + public function getSubPathname(): string + { + $directory_iterator = $this->getInnerIterator(); + assert($directory_iterator instanceof \RecursiveDirectoryIterator); + return $directory_iterator->getSubPathname(); + } }