mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-09 10:16:36 +02:00
Merge pull request #1290 from nickvergessen/ticket/11362
Correctly sanitise the directory path in finder
This commit is contained in:
@@ -60,6 +60,7 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case
|
||||
$this->db,
|
||||
$this->config,
|
||||
$this->migrator,
|
||||
new phpbb_filesystem(),
|
||||
'phpbb_ext',
|
||||
dirname(__FILE__) . '/../../phpBB/',
|
||||
'.php',
|
||||
|
@@ -6,6 +6,7 @@
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
||||
|
||||
class phpbb_extension_finder_test extends phpbb_test_case
|
||||
{
|
||||
@@ -142,13 +143,28 @@ class phpbb_extension_finder_test extends phpbb_test_case
|
||||
);
|
||||
}
|
||||
|
||||
public function test_uncleansub_directory_get_classes()
|
||||
{
|
||||
$classes = $this->finder
|
||||
->directory('/sub/../sub/type')
|
||||
->get_classes();
|
||||
|
||||
sort($classes);
|
||||
$this->assertEquals(
|
||||
array(
|
||||
'phpbb_ext_foo_sub_type_alternative',
|
||||
),
|
||||
$classes
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* These do not work because of changes with PHPBB3-11386
|
||||
* They do not seem neccessary to me, so I am commenting them out for now
|
||||
public function test_get_classes_create_cache()
|
||||
{
|
||||
$cache = new phpbb_mock_cache;
|
||||
$finder = new phpbb_extension_finder($this->extension_manager, dirname(__FILE__) . '/', $cache, '.php', '_custom_cache_name');
|
||||
$finder = new phpbb_extension_finder($this->extension_manager, new phpbb_filesystem(), dirname(__FILE__) . '/', $cache, '.php', '_custom_cache_name');
|
||||
$files = $finder->suffix('_class.php')->get_files();
|
||||
|
||||
$expected_files = array(
|
||||
@@ -188,6 +204,7 @@ class phpbb_extension_finder_test extends phpbb_test_case
|
||||
|
||||
$finder = new phpbb_extension_finder(
|
||||
$this->extension_manager,
|
||||
new phpbb_filesystem(),
|
||||
dirname(__FILE__) . '/',
|
||||
new phpbb_mock_cache(array(
|
||||
'_ext_finder' => array(
|
||||
|
@@ -112,6 +112,7 @@ class phpbb_extension_manager_test extends phpbb_database_test_case
|
||||
$db,
|
||||
$config,
|
||||
$migrator,
|
||||
new phpbb_filesystem(),
|
||||
'phpbb_ext',
|
||||
dirname(__FILE__) . '/',
|
||||
'.' . $php_ext,
|
||||
|
@@ -64,6 +64,7 @@ class metadata_manager_test extends phpbb_database_test_case
|
||||
$this->db,
|
||||
$this->config,
|
||||
$this->migrator,
|
||||
new phpbb_filesystem(),
|
||||
'phpbb_ext',
|
||||
$this->phpbb_root_path,
|
||||
$this->phpEx,
|
||||
|
@@ -7,11 +7,17 @@
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
||||
|
||||
class phpbb_clean_path_test extends phpbb_test_case
|
||||
class phpbb_filesystem_clean_path_test extends phpbb_test_case
|
||||
{
|
||||
public function clean_path_test_data()
|
||||
protected $filesystem;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->filesystem = new phpbb_filesystem();
|
||||
}
|
||||
|
||||
public function clean_path_data()
|
||||
{
|
||||
return array(
|
||||
array('foo', 'foo'),
|
||||
@@ -33,12 +39,10 @@ class phpbb_clean_path_test extends phpbb_test_case
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider clean_path_test_data
|
||||
* @dataProvider clean_path_data
|
||||
*/
|
||||
public function test_clean_path($input, $expected)
|
||||
{
|
||||
$output = phpbb_clean_path($input);
|
||||
|
||||
$this->assertEquals($expected, $output);
|
||||
$this->assertEquals($expected, $this->filesystem->clean_path($input));
|
||||
}
|
||||
}
|
@@ -14,5 +14,6 @@ class phpbb_mock_extension_manager extends phpbb_extension_manager
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = '.php';
|
||||
$this->extensions = $extensions;
|
||||
$this->filesystem = new phpbb_filesystem();
|
||||
}
|
||||
}
|
||||
|
@@ -153,6 +153,7 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||
$db,
|
||||
$config,
|
||||
$migrator,
|
||||
new phpbb_filesystem(),
|
||||
self::$config['table_prefix'] . 'ext',
|
||||
dirname(__FILE__) . '/',
|
||||
'.' . $php_ext,
|
||||
|
Reference in New Issue
Block a user