bobthecow/mustache.php — pull request #208 by smarden1 (2014-06-18 23:04:01+00:00)
Title: Uneven braces in triples are incorrectly swallowing a character

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.