encoding.xml: fix parsing for self closing empty tags (#19907)

This commit is contained in:
Subhomoy Haldar 2023-11-17 08:51:46 +00:00 committed by GitHub
parent 66181f05bd
commit 1482a2f28d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -562,7 +562,7 @@ pub fn parse_single_node(first_char u8, mut reader io.Reader) !XMLNode {
tag_contents := contents.str().trim_space()
parts := tag_contents.split_any(' \t\n')
name := parts[0]
name := parts[0].trim_right('/')
// Check if it is a self-closing tag
if tag_contents.ends_with('/') {

View File

@ -7,6 +7,7 @@ const (
<c id="c2">
Sample Text
</c>
<empty/>
<c id="c3"/>
<abc id="c4"/>
<xyz id="c5"/>
@ -34,6 +35,10 @@ const (
'Sample Text',
]
},
XMLNode{
name: 'empty'
attributes: {}
},
XMLNode{
name: 'c'
attributes: {