Skip to content

Commit

Permalink
Merge pull request ballerina-platform#41693 from poorna2152/xml_close_gt
Browse files Browse the repository at this point in the history
Fix compiler crash in invalid xml with missing closing tag
  • Loading branch information
lochana-chathura authored Nov 20, 2023
2 parents 263039d + f95c5fb commit d1d14c1
Show file tree
Hide file tree
Showing 6 changed files with 435 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,12 @@ private STNode parseXMLText() {
* @return XML char-data token
*/
private STNode parseCharData() {
return consume();
STToken token = consume();
if (token.kind != SyntaxKind.XML_TEXT_CONTENT) {
return STNodeFactory.createLiteralValueToken(SyntaxKind.XML_TEXT_CONTENT, token.text(),
token.leadingMinutiae(), token.trailingMinutiae(), token.diagnostics());
}
return token;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,8 @@ public void testMissingNameInXMLEndTag() {
public void testMissingQuoteInXMLAttributeValue() {
testFile("xml-template/xml_template_source_35.bal", "xml-template/xml_template_assert_35.json");
}

public void testMissingClosingAndNextStartingAngleBracket() {
testFile("xml-template/xml_template_source_36.bal", "xml-template/xml_template_assert_36.json");
}
}
Loading

0 comments on commit d1d14c1

Please sign in to comment.