mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-13 02:46:29 +00:00
added an exception for unclosed tags
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
* 1.2.0
|
||||
|
||||
* enhanced the exception when a tag remains unclosed
|
||||
* added support for empty Countable objects for the "empty" test
|
||||
* fixed algorithm that determines if a template using inheritance is valid (no output between block definitions)
|
||||
* added better support for encoding problems when escaping a string (available as of PHP 5.4)
|
||||
|
||||
@@ -140,6 +140,10 @@ class Twig_Parser implements Twig_ParserInterface
|
||||
|
||||
$subparser = $this->handlers->getTokenParser($token->getValue());
|
||||
if (null === $subparser) {
|
||||
if (null !== $test) {
|
||||
throw new Twig_Error_Syntax(sprintf('Unexpected tag name "%s" (expecting closing tag for the "%s" tag defined near line %s)', $token->getValue(), $test[0]->getTag(), $lineno), $token->getLine(), $this->stream->getFilename());
|
||||
}
|
||||
|
||||
throw new Twig_Error_Syntax(sprintf('Unknown tag name "%s"', $token->getValue()), $token->getLine(), $this->stream->getFilename());
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
Exception for an unclosed tag
|
||||
--TEMPLATE--
|
||||
{% block foo %}
|
||||
{% if foo %}
|
||||
|
||||
|
||||
|
||||
|
||||
{% for i in fo %}
|
||||
|
||||
|
||||
|
||||
{% endfor %}
|
||||
|
||||
|
||||
|
||||
{% endblock %}
|
||||
--EXCEPTION--
|
||||
Twig_Error_Syntax: Unexpected tag name "endblock" (expecting closing tag for the "if" tag defined near line 4) in "index.twig" at line 16
|
||||
Reference in New Issue
Block a user