Пример #1
0
 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&lt;b&gt;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&lt;b&gt;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('');
 }
Пример #2
0
 public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
 {
     $compiler->setAutoEscape(array_pop(self::$stack));
     return $content;
 }
Пример #3
0
 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&LT;B&GT;CA<B>C", $this->dwoo->get($tpl, array('foo' => 'a<b>c'), $cmp));
 }
Пример #4
0
 public function testDoubleEscapingOnAssignments()
 {
     $tpl = new Dwoo_Template_String('{$bar = $foo}{$foo}{$bar}');
     $tpl->forceCompilation();
     $cmp = new Dwoo_Compiler();
     $cmp->setAutoEscape(true);
     $this->assertEquals('a&#039;ba&#039;b', $this->dwoo->get($tpl, array('foo' => "a'b"), $cmp));
 }