* 1.4.0
+ * added a better error message when a template is empty but contain a BOM
* fixed in operator for empty strings
* fixed the "defined" test and the "default" filter (now works with more than one call (foo.bar.foo) and for both values of the strict_variables option)
* changed the way extensions are loaded (addFilter/addFunction/addGlobal/addTest/addNodeVisitor/addTokenParser/addExtension can now be called in any order)
||
(!$node instanceof Twig_Node_Text && !$node instanceof Twig_Node_BlockReference && $node instanceof Twig_NodeOutputInterface)
) {
- throw new Twig_Error_Syntax('A template that extends another one cannot have a body.', $node->getLine(), $this->stream->getFilename());
+ if (false !== strpos((string) $node, chr(0xEF).chr(0xBB).chr(0xBF))) {
+ throw new Twig_Error_Syntax('A template that extends another one cannot have a body but a byte order mark (BOM) has been detected; it must be removed.', $node->getLine(), $this->stream->getFilename());
+ } else {
+ throw new Twig_Error_Syntax('A template that extends another one cannot have a body.', $node->getLine(), $this->stream->getFilename());
+ }
}
// bypass "set" nodes as they "capture" the output
);
}
+ /**
+ * @expectedException Twig_Error_Syntax
+ * @expectedExceptionMessage A template that extends another one cannot have a body but a byte order mark (BOM) has been detected; it must be removed at line 0.
+ */
+ public function testFilterBodyNodesWithBOM()
+ {
+ $parser = $this->getParserForFilterBodyNodes();
+ $parser->filterBodyNodes(new Twig_Node_Text(chr(0xEF).chr(0xBB).chr(0xBF), 0));
+ }
+
protected function getParserForFilterBodyNodes()
{
$parser = new TestParser(new Twig_Environment());