public function testAutoEscape() { $cmp = new Dwoo_Compiler(); $cmp->setAutoEscape(true); $tpl = new Dwoo_Template_String('{$foo}{auto_escape off}{$foo}{/}'); $tpl->forceCompilation(); $this->assertEquals("a<b>ca<b>c", $this->dwoo->get($tpl, array('foo' => 'a<b>c'), $cmp)); $tpl = new Dwoo_Template_String('{$foo}{auto_escape true}{$foo}{/}'); $tpl->forceCompilation(); $this->assertEquals("a<b>ca<b>c", $this->dwoo->get($tpl, array('foo' => 'a<b>c'))); // fixes the init call not being called (which is normal) $fixCall = new Dwoo_Plugin_auto_escape($this->dwoo); $fixCall->init(''); }
public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content) { $compiler->setAutoEscape(array_pop(self::$stack)); return $content; }
public function testAutoEscapeWithFunctionCall() { $cmp = new Dwoo_Compiler(); $cmp->setAutoEscape(true); $this->assertEquals(true, $cmp->getAutoEscape()); $tpl = new Dwoo_Template_String('{upper $foo}{upper $foo|safe}'); $tpl->forceCompilation(); $this->assertEquals("A<B>CA<B>C", $this->dwoo->get($tpl, array('foo' => 'a<b>c'), $cmp)); }
public function testDoubleEscapingOnAssignments() { $tpl = new Dwoo_Template_String('{$bar = $foo}{$foo}{$bar}'); $tpl->forceCompilation(); $cmp = new Dwoo_Compiler(); $cmp->setAutoEscape(true); $this->assertEquals('a'ba'b', $this->dwoo->get($tpl, array('foo' => "a'b"), $cmp)); }