Repository navigation
Check start tags were matched to an end tag - #923
Merged
Merged
Conversation
Member
|
Are there already tests for this cases? |
Member
|
actually some tests fail |
paulharris
force-pushed
the
fix-mustache-unmatched
branch
from
October 18, 2024 02:17
3055ee8 to
b90a739
Compare
Contributor
Author
|
Sorry about that, I didn't check the tests. You can see the infinite loop by checking out this branch, but wind back one commit to before the fix. |
Contributor
Author
|
I've been using my fix with success, just need a review to push this through. |
mrozigor
approved these changes
Dec 2, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.posCrow/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.