aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--phpBB/includes/template/renderer_eval.php2
-rw-r--r--tests/template/renderer_eval_test.php31
2 files changed, 32 insertions, 1 deletions
diff --git a/phpBB/includes/template/renderer_eval.php b/phpBB/includes/template/renderer_eval.php
index 11e2a30f06..2c05a1c1df 100644
--- a/phpBB/includes/template/renderer_eval.php
+++ b/phpBB/includes/template/renderer_eval.php
@@ -55,6 +55,6 @@ class phpbb_template_renderer_eval implements phpbb_template_renderer
$_rootref = &$context->get_root_ref();
$_lang = $lang;
- eval($this->code);
+ eval(' ?>' . $this->code . '<?php ');
}
}
diff --git a/tests/template/renderer_eval_test.php b/tests/template/renderer_eval_test.php
new file mode 100644
index 0000000000..c30516ba97
--- /dev/null
+++ b/tests/template/renderer_eval_test.php
@@ -0,0 +1,31 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2011 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+class phpbb_template_renderer_eval_test extends phpbb_test_case
+{
+ public function test_eval()
+ {
+ $compiled_code = '<a href="<?php echo \'Test\'; ?>">';
+ $valid_code = '<a href="Test">';
+ $context = new phpbb_template_context();
+ $template = new phpbb_template_renderer_eval($compiled_code, NULL);
+ ob_start();
+ try
+ {
+ $template->render($context, array());
+ }
+ catch (Exception $exception)
+ {
+ ob_end_clean();
+ throw $exception;
+ }
+ $output = ob_get_clean();
+ $this->assertEquals($valid_code, $output);
+ }
+}