Skip to content

Commit

Permalink
Remove exceptions on multiple * in dynamic names.
Browse files Browse the repository at this point in the history
Per the finalized spec, these should be treated as lookup failures (i.e. rendered as empty strings) rather than exceptions.
  • Loading branch information
bobthecow committed Aug 23, 2022
1 parent af4f8f7 commit 93f824d
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 34 deletions.
6 changes: 0 additions & 6 deletions src/Mustache/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,6 @@ private function getDynamicName(array $token)
$isDynamic = true;
}

// Two stars is two many!
if (preg_match('/^\s*\*\s*/', $name) || preg_match('/[|.]\s*\*/', $name)) {
$msg = sprintf('Invalid dynamic name: %s', $name);
throw new Mustache_Exception_SyntaxException($msg, $token);
}

return array($name, $isDynamic);
}

Expand Down
28 changes: 0 additions & 28 deletions test/Mustache/Test/Functional/DynamicPartialsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,6 @@ public function setUp()
));
}

public function getInvalidDynamicNamesExamples()
{
return array(
array('{{> **foo}}'),
array('{{> *foo.*bar}}'),
array('{{> foo.*bar}}'),
array('{{ *foo }}'),
array('{{{ *foo }}}'),
array('{{& *foo }}'),
array('{{# *foo }}{{/ *foo }}'),
array('{{^ *foo }}{{/ *foo }}'),
array('{{% FILTERS}}{{> *foo | *bar}}'),
array('{{% FILTERS}}{{> foo | *bar}}'),
array('{{% BLOCKS }}{{$ *foo }}{{/ *foo }}'),
);
}

/**
* @dataProvider getInvalidDynamicNamesExamples
* @expectedException Mustache_Exception_SyntaxException
* @expectedExceptionMessage Invalid dynamic name:
*/
public function testInvalidDynamicNamesExamples($template)
{
$this->mustache->render($template);
}


public function getValidDynamicNamesExamples()
{
// technically not all dynamic names, but also not invalid
Expand Down

0 comments on commit 93f824d

Please sign in to comment.