Skip to content

Commit 33f649c

Browse files
authored
fix parse exception "tag was never closed" with line break (#159)
1 parent d81a526 commit 33f649c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/Liquid/AbstractBlock.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function getNodelist()
5252
public function parse(array &$tokens)
5353
{
5454
$startRegexp = new Regexp('/^' . Liquid::get('TAG_START') . '/');
55-
$tagRegexp = new Regexp('/^' . Liquid::get('TAG_START') . Liquid::get('WHITESPACE_CONTROL') . '?\s*(\w+)\s*(.*?)' . Liquid::get('WHITESPACE_CONTROL') . '?' . Liquid::get('TAG_END') . '$/');
55+
$tagRegexp = new Regexp('/^' . Liquid::get('TAG_START') . Liquid::get('WHITESPACE_CONTROL') . '?\s*(\w+)\s*(.*?)' . Liquid::get('WHITESPACE_CONTROL') . '?' . Liquid::get('TAG_END') . '$/s');
5656
$variableStartRegexp = new Regexp('/^' . Liquid::get('VARIABLE_START') . '/');
5757

5858
$this->nodelist = array();

tests/Liquid/Tag/TagIfTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,14 @@ public function testSyntaxErrorNotClosed()
232232
$this->assertTemplateResult('', '{% if jerry == 1 %}');
233233
}
234234

235+
public function testSyntaxErrorNotClosedLineBreak()
236+
{
237+
$this->expectException(\Liquid\Exception\ParseException::class);
238+
$this->expectExceptionMessage('if tag was never closed');
239+
240+
$this->assertTemplateResult('', "{% if jerry\n == 1 %}");
241+
}
242+
235243
/**
236244
*/
237245
public function testSyntaxErrorEnd()

0 commit comments

Comments
 (0)