Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix panic in Set Delimiter parsing. #91

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fiirhok
Copy link

@fiirhok fiirhok commented Dec 13, 2024

Mustache supports Set Delimter tags, of the form {{=<open tag> <close tag>=}}, which is used to change the delimiters from {{ and }}. Prior to this commit, if there was a sequence that looked like the start of a Set Delimiter tag, but there was not a complete Set Delimiter tag, the library could panic.

This commit:
* factors out the Set Delimiter tag parsing into a new function, 'parseCustomDelimiter()'
* adds checks to make sure an incomplete tag doesn't cause an access off the end of a slice
* treats an incomplete Set Delimiter (like {{=}}) as a normaal tag

This behaviour matches the mustache playground at
https://jgonggrijp.gitlab.io/wontache/playground.html. I tried to match the behaviour of the Ruby implementation, but it seems to be inconsistent in this case.

Mustache supports Set Delimter tags, of the form `{{=<open tag> <close tag>=}}`,
which is used to change the delimiters from `{{` and `}}`. Prior to this
commit, if there was a sequence that looked like the start of a Set
Delimiter tag, but there was not a complete Set Delimiter tag, the
library could panic.

This commit:
    * factors out the Set Delimiter tag parsing into a new function,
      'parseCustomDelimiter()'
    * adds checks to make sure an incomplete tag doesn't cause an access
      off the end of a slice
    * treats an incomplete Set Delimiter (like `{{=}}`) as a normaal
      tag

This behaviour matches the mustache playground at
https://jgonggrijp.gitlab.io/wontache/playground.html. I tried to match
the behaviour of the Ruby implementation, but it seems to be
inconsistent in this case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant