mirror of
https://github.com/vlang/v.git
synced 2025-09-08 23:07:19 -04:00
encoding.xml: fix parsing for self closing empty tags (#19907)
This commit is contained in:
parent
66181f05bd
commit
1482a2f28d
@ -562,7 +562,7 @@ pub fn parse_single_node(first_char u8, mut reader io.Reader) !XMLNode {
|
|||||||
tag_contents := contents.str().trim_space()
|
tag_contents := contents.str().trim_space()
|
||||||
|
|
||||||
parts := tag_contents.split_any(' \t\n')
|
parts := tag_contents.split_any(' \t\n')
|
||||||
name := parts[0]
|
name := parts[0].trim_right('/')
|
||||||
|
|
||||||
// Check if it is a self-closing tag
|
// Check if it is a self-closing tag
|
||||||
if tag_contents.ends_with('/') {
|
if tag_contents.ends_with('/') {
|
||||||
|
@ -7,6 +7,7 @@ const (
|
|||||||
<c id="c2">
|
<c id="c2">
|
||||||
Sample Text
|
Sample Text
|
||||||
</c>
|
</c>
|
||||||
|
<empty/>
|
||||||
<c id="c3"/>
|
<c id="c3"/>
|
||||||
<abc id="c4"/>
|
<abc id="c4"/>
|
||||||
<xyz id="c5"/>
|
<xyz id="c5"/>
|
||||||
@ -34,6 +35,10 @@ const (
|
|||||||
'Sample Text',
|
'Sample Text',
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
XMLNode{
|
||||||
|
name: 'empty'
|
||||||
|
attributes: {}
|
||||||
|
},
|
||||||
XMLNode{
|
XMLNode{
|
||||||
name: 'c'
|
name: 'c'
|
||||||
attributes: {
|
attributes: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user