-
Notifications
You must be signed in to change notification settings - Fork 14
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
TXmlReader.ParseComment throws parser error for valid XML comments #11
Comments
I added the following test to expose this issue.
The test passes with the suggested changes given in my previous comment. However it seems that
But I think that would be reasonable. |
tschroff
added a commit
to tschroff/Neslib.Xml
that referenced
this issue
Oct 19, 2023
tschroff
added a commit
to tschroff/Neslib.Xml
that referenced
this issue
Oct 19, 2023
…mplete comment end marker. Besides that, ignore all triangular brackets. Adapt unittests to this new behavior.
neslib
added a commit
that referenced
this issue
Oct 19, 2023
Suggested fix for issue #11 (comment parsing)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Symptom
The while loop in
TXmlReader.ParseComment
which should handle nested angular brackets seems to be unable to handle the following valid XML comment properly and subsequently the method throws a parser error exception about an invalid comment.Analysis
Since the while loop expects nested angular brackets to always start with an opening bracket, the number of levels in the above example immediately decreases to 0 at the end of the first line and the loop is exited. The "--" then cannot be found before the current position and the mentiond parser error is raised.
Also, the loop seems to expect an identical amount of opening and closing angular brackets. This seems to be an invalid assumption for a comment that can contain anything.
So I expect this
to also throw an exception.
I can also think of examples that might cause the parser to leave to scope of the comment:
Suggestions
I think the while loop should look for the first occurrence of the closing sequence "-->" instead of counting the level of nested angular brackets.
Maybe something like this:
Thank you!
The text was updated successfully, but these errors were encountered: