bobthecow/mustache.php — pull request #209 by smarden1 (2014-06-18 23:58:45+00:00)
Title: Uneven braces in triples are incorrectly swallowing a character [repost of 208]

This is the same as https://github.com/bobthecow/mustache.php/pull/208 but only includes the relevant files.

I found this issue the other day where triple tags that are incorrectly formatted are being used as if they were properly formatted. I'm not sure if this is the correct and expected behavior, but what is certainly not right in this case, is that they are incorrectly swallowing the next character. This gist should demonstrate the issue.

https://gist.github.com/smarden1/470f67980f006832a667

Without looking at that gist, the issue is that the template <h1>{{{ text }}</h1> is not properly closed. Unfortunately, what happens here is that the next character is swallowed and disappears, making the result be <h1>some_text/h1>, which is not proper html.

For this pull request, I had the tokenizer throw a SynaxException as it is unclear what should happen in this case.

I looked into other implementations of mustache and they are treating this in different ways. I believe the ruby one throws and error and the js one continues along until it finds the appropriate closing triple.