mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[feature/template-engine] Fixed absolute path PHP includes, added test.
PHPBB3-9726
This commit is contained in:
parent
efda4da19f
commit
6ae5a64f6c
3 changed files with 33 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,5 +1,6 @@
|
||||||
*~
|
*~
|
||||||
phpunit.xml
|
phpunit.xml
|
||||||
|
phpBB/cache/*.html
|
||||||
phpBB/cache/*.php
|
phpBB/cache/*.php
|
||||||
phpBB/cache/queue.php.lock
|
phpBB/cache/queue.php.lock
|
||||||
phpBB/config.php
|
phpBB/config.php
|
||||||
|
|
|
@ -529,7 +529,14 @@ class phpbb_template
|
||||||
*/
|
*/
|
||||||
public function _php_include($filename)
|
public function _php_include($filename)
|
||||||
{
|
{
|
||||||
$file = $this->phpbb_root_path . $filename;
|
if (is_absolute($filename))
|
||||||
|
{
|
||||||
|
$file = $filename;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$file = $this->phpbb_root_path . $filename;
|
||||||
|
}
|
||||||
|
|
||||||
if (!file_exists($file))
|
if (!file_exists($file))
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,4 +24,28 @@ class phpbb_template_includephp_test extends phpbb_template_template_test_case
|
||||||
|
|
||||||
$GLOBALS['config']['tpl_allow_php'] = false;
|
$GLOBALS['config']['tpl_allow_php'] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_includephp_absolute()
|
||||||
|
{
|
||||||
|
$path_to_php = dirname(__FILE__) . '/templates/_dummy_include.php.inc';
|
||||||
|
$this->assertTrue(is_absolute($path_to_php));
|
||||||
|
$template_text = "Path is absolute.\n<!-- INCLUDEPHP $path_to_php -->";
|
||||||
|
|
||||||
|
$cache_dir = dirname($this->template->cachepath) . '/';
|
||||||
|
$fp = fopen($cache_dir . 'includephp_absolute.html', 'w');
|
||||||
|
fputs($fp, $template_text);
|
||||||
|
fclose($fp);
|
||||||
|
|
||||||
|
$GLOBALS['config']['tpl_allow_php'] = true;
|
||||||
|
|
||||||
|
$this->template->set_custom_template($cache_dir, 'tests');
|
||||||
|
$cache_file = $this->template->cachepath . 'includephp_absolute.html.php';
|
||||||
|
|
||||||
|
$this->run_template('includephp_absolute.html', array(), array(), array(), "Path is absolute.\ntesting included php", $cache_file);
|
||||||
|
|
||||||
|
$this->template->set_filenames(array('test' => 'includephp_absolute.html'));
|
||||||
|
$this->assertEquals("Path is absolute.\ntesting included php", $this->display('test'), "Testing INCLUDEPHP");
|
||||||
|
|
||||||
|
$GLOBALS['config']['tpl_allow_php'] = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue