Check start tags were matched to an end tag #923
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Template:
Context:
{ "username": "" }
The problem appears to be in
ActionType::ElseBlock
, which find the context, but doesn't have a switch case forjson::type::String
, and instead setscurrent=action.pos
Crow/include/crow/mustache.h
Line 349 in 25ca2f5
For this template, there are 2 actions.
At this point we are on the second action (current=1)
But this action's "pos" is = 0.
So, current is reset to zero, and it loops through again and again, never progressing.
This seems related to #899
I think the problem is pos is never set to a valid point... this is done in case'/', ie when the parser sees the end tag.
But, if there is never an end-tag, it never checks if there are unmatched pairs, and pos is never set.
So, I've adjusted the code so it always expects a non-negative pos.
pos is initialised by default to -1 for start tags.
And end tag will match it and set it to a valid pos.
For all other normal tags, it is initialised to zero.
THIS was a quick first-pass patch, as I'm not familiar with mustache, so I imagine this patch is NOT COMPLETE.
It needs to be run through a test suite.