Skip to content

Commit

Permalink
encoding.xml: fix parsing for self closing empty tags (#19907)
Browse files Browse the repository at this point in the history
  • Loading branch information
hungrybluedev committed Nov 17, 2023
1 parent 66181f0 commit 1482a2f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion vlib/encoding/xml/parser.v
Expand Up @@ -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('/') {
Expand Down
5 changes: 5 additions & 0 deletions vlib/encoding/xml/parser_test.v
Expand Up @@ -7,6 +7,7 @@ const (
<c id="c2">
Sample Text
</c>
<empty/>
<c id="c3"/>
<abc id="c4"/>
<xyz id="c5"/>
Expand Down Expand Up @@ -34,6 +35,10 @@ const (
'Sample Text',
]
},
XMLNode{
name: 'empty'
attributes: {}
},
XMLNode{
name: 'c'
attributes: {
Expand Down

0 comments on commit 1482a2f

Please sign in to comment.