Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion vlib/encoding/xml/parser.v
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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