1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-31 22:10:45 +02:00

[ticket/16967] Remove support for INCLUDEPHP and PHP/ENDPHP in templates

PHPBB3-16967
This commit is contained in:
Marc Alexander
2022-02-21 21:24:25 +01:00
parent 8284dc2c10
commit d868dbe3aa
20 changed files with 36 additions and 441 deletions

View File

@@ -264,16 +264,6 @@ class phpbb_template_extension_test extends phpbb_template_template_test_case
'',
[]
],
[
'extension_config_test.html',
[
'config_name' => 'tpl_allow_php',
],
[],
[],
'',
[]
],
];
}

View File

@@ -1,62 +0,0 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
use phpbb\filesystem\helper as filesystem_helper;
require_once __DIR__ . '/template_test_case.php';
class phpbb_template_includephp_test extends phpbb_template_template_test_case
{
public function test_includephp_relative()
{
$this->setup_engine(array('tpl_allow_php' => true));
$this->run_template('includephp_relative.html', array(), array(), array(), "Path is relative to board root.\ntesting included php");
$this->template->set_filenames(array('test' => 'includephp_relative.html'));
$this->assertEquals("Path is relative to board root.\ntesting included php", $this->display('test'), "Testing INCLUDEPHP");
}
public function test_includephp_variables()
{
$this->setup_engine(array('tpl_allow_php' => true));
$this->run_template('includephp_variables.html', array('TEMPLATES' => 'templates'), array(), array(), "Path includes variables.\ntesting included php");
$this->template->set_filenames(array('test' => 'includephp_variables.html'));
$this->assertEquals("Path includes variables.\ntesting included php", $this->display('test'), "Testing INCLUDEPHP");
}
public function test_includephp_absolute()
{
global $phpbb_root_path;
$path_to_php = str_replace('\\', '/', __DIR__) . '/templates/_dummy_include.php.inc';
$this->assertTrue(filesystem_helper::is_absolute_path($path_to_php));
$template_text = "Path is absolute.\n<!-- INCLUDEPHP $path_to_php -->";
$cache_dir = $phpbb_root_path . 'cache/';
$fp = fopen($cache_dir . 'includephp_absolute.html', 'w');
fputs($fp, $template_text);
fclose($fp);
$this->setup_engine(array('tpl_allow_php' => true));
$this->template->set_custom_style('tests', $cache_dir);
$this->run_template('includephp_absolute.html', array(), array(), array(), "Path is absolute.\ntesting included php");
$this->template->set_filenames(array('test' => 'includephp_absolute.html'));
$this->assertEquals("Path is absolute.\ntesting included php", $this->display('test'), "Testing INCLUDEPHP");
}
}

View File

@@ -1,31 +0,0 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
require_once __DIR__ . '/../template_test_case.php';
class phpbb_template_subdir_includephp_from_subdir_test extends phpbb_template_template_test_case
{
// Exact copy of test_includephp_relatve from ../includephp_test.php.
// Verifies that relative php inclusion works when including script
// (and thus current working directory) is in a subdirectory of
// board root.
public function test_includephp_relative()
{
$this->setup_engine(array('tpl_allow_php' => true));
$this->run_template('includephp_relative.html', array(), array(), array(), "Path is relative to board root.\ntesting included php");
$this->template->set_filenames(array('test' => 'includephp_relative.html'));
$this->assertEquals("Path is relative to board root.\ntesting included php", $this->display('test'), "Testing INCLUDEPHP");
}
}

View File

@@ -256,13 +256,6 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
. str_repeat("pass\n", 3) . "\n"
. str_repeat("pass\n", 2) . "\n"),
),
array(
'php.html',
array(),
array(),
array(),
'',
),
array(
'include.html',
array('VARIABLE' => 'value'),
@@ -644,24 +637,6 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
$this->assertEquals(array('POSITION' => 'O3M2', 'ONE' => true, 'TWO' => 'two', 'THREE' => 3), $this->template->retrieve_block_vars('outer[2].middle[1]', array()), 'Retrieve all vars from a block in the template');
}
public function test_php()
{
global $phpbb_root_path;
$template_text = '<!-- PHP -->echo "test";<!-- ENDPHP -->';
$cache_dir = $phpbb_root_path . 'cache/';
$fp = fopen($cache_dir . 'php.html', 'w');
fputs($fp, $template_text);
fclose($fp);
$this->setup_engine(array('tpl_allow_php' => true));
$this->template->set_custom_style('tests', $cache_dir);
$this->run_template('php.html', array(), array(), array(), 'test');
}
public function alter_block_array_data()
{
return array(

View File

@@ -64,7 +64,6 @@ class phpbb_template_template_test_case extends phpbb_test_case
{
$defaults = array(
'load_tplcompile' => true,
'tpl_allow_php' => false,
);
return $defaults;
}

View File

@@ -1,2 +0,0 @@
Path is relative to board root.
<!-- INCLUDEPHP ../tests/template/templates/_dummy_include.php.inc -->

View File

@@ -1,2 +0,0 @@
Path includes variables.
<!-- INCLUDEPHP ../tests/template/{TEMPLATES}/_dummy_include.php.inc -->

View File

@@ -1 +0,0 @@
<!-- PHP -->echo "test";<!-- ENDPHP -->