html.parser: fix ‘<![CDATA[ ... ]]>’ handling not capturing ‘]’ #24720
+12
−3
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.


Per documentation, the unknown_decl method is called with ‘the entire
contents of the declaration inside the <![...]> markup.’ However,
this is not quite the case for ‘’ where the first of
the two final closing square brackets should be included but isn’t.
In other words, for such declaration unknown_decl is called with
‘CDATA[...’ string (observe unmatched brackets).
Not including the closing bracket doesn’t fit the documentation but
also makes it impossible to output the declaration without change
since ‘"<![" + data + "]>"’ eats one of the brackets at the end.
Fix by including the first of the closing brackets when calling
unknown_decl.