Commit 2c45013f by Jordi Boggiano

Fixed endless loop when parsing an invalid else block

parent 586ef2ac
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
thanks to Dominik del Bondio for the patch thanks to Dominik del Bondio for the patch
* Adapters: Agavi: Added support for multiple plugin directories in the * Adapters: Agavi: Added support for multiple plugin directories in the
config, thanks to Mike Seth for the patch config, thanks to Mike Seth for the patch
* Fixed endless loop when parsing an invalid else block
* Fixed custom compilable plugins not being recognized as such * Fixed custom compilable plugins not being recognized as such
[2010-02-07] 1.1.1 [2010-02-07] 1.1.1
......
...@@ -39,6 +39,9 @@ class Dwoo_Plugin_else extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Blo ...@@ -39,6 +39,9 @@ class Dwoo_Plugin_else extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Blo
while (true) { while (true) {
$preContent .= $compiler->removeTopBlock(); $preContent .= $compiler->removeTopBlock();
$block =& $compiler->getCurrentBlock(); $block =& $compiler->getCurrentBlock();
if (!$block) {
throw new Dwoo_Compilation_Exception($compiler, 'An else block was found but it was not preceded by an if or other else-able construct');
}
$interfaces = class_implements($block['class'], false); $interfaces = class_implements($block['class'], false);
if (in_array('Dwoo_IElseable', $interfaces) !== false) { if (in_array('Dwoo_IElseable', $interfaces) !== false) {
break; break;
......
...@@ -748,6 +748,16 @@ fail ...@@ -748,6 +748,16 @@ fail
$tpl->forceCompilation(); $tpl->forceCompilation();
$this->assertEquals('foo', $this->dwoo->get($tpl, array())); $this->assertEquals('foo', $this->dwoo->get($tpl, array()));
} }
/**
* @expectedException Dwoo_Compilation_Exception
*/
public function testElseWithoutIfIsInvalid()
{
$tpl = new Dwoo_Template_String('{else}1{/}');
$tpl->forceCompilation();
$this->dwoo->get($tpl, array(), $this->compiler);
}
} }
function excessArgsHelper($a) { function excessArgsHelper($a) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment