setUpSmarty(__DIR__); $this->smarty->setEscapeHtml(true); } /** * test 'escapeHtml' property */ public function testAutoEscape() { $tpl = $this->smarty->createTemplate('eval:{$foo}'); $tpl->assign('foo', ''); $this->assertEquals("<a@b.c>", $this->smarty->fetch($tpl)); } /** * test 'escapeHtml' property * @group issue906 */ public function testAutoEscapeDoesNotEscapeFunctionPlugins() { $this->smarty->registerPlugin( Smarty::PLUGIN_FUNCTION, 'horizontal_rule', function ($params, $smarty) { return "
"; } ); $tpl = $this->smarty->createTemplate('eval:{horizontal_rule}'); $this->assertEquals("
", $this->smarty->fetch($tpl)); } /** * test 'escapeHtml' property * @group issue906 */ public function testAutoEscapeDoesNotEscapeBlockPlugins() { $this->smarty->registerPlugin( Smarty::PLUGIN_BLOCK, 'paragraphify', function ($params, $content) { return $content == null ? null : "

".$content."

"; } ); $tpl = $this->smarty->createTemplate('eval:{paragraphify}hi{/paragraphify}'); $this->assertEquals("

hi

", $this->smarty->fetch($tpl)); } }