mirror of
https://github.com/mikefarah/yq.git
synced 2026-09-01 14:14:52 +08:00
Fixed xml decode bug when there is content after a comment
This commit is contained in:
@@ -245,7 +245,7 @@ func (dec *xmlDecoder) decodeXML(root *xmlNode) error {
|
||||
}
|
||||
case xml.CharData:
|
||||
// Extract XML data (if any)
|
||||
elem.n.Data = trimNonGraphic(string(se))
|
||||
elem.n.Data = elem.n.Data + trimNonGraphic(string(se))
|
||||
if elem.n.Data != "" {
|
||||
elem.state = "chardata"
|
||||
log.Debug("chardata [%v] for %v", elem.n.Data, elem.label)
|
||||
|
||||
@@ -233,6 +233,11 @@ const expectedXmlWithProcInstAndDirectives = `<?xml version="1.0"?>
|
||||
`
|
||||
|
||||
var xmlScenarios = []formatScenario{
|
||||
{
|
||||
skipDoc: true,
|
||||
input: "<root>value<!-- comment--> </root>",
|
||||
expected: "root: value # comment\n",
|
||||
},
|
||||
{
|
||||
description: "Parse xml: simple",
|
||||
subdescription: "Notice how all the values are strings, see the next example on how you can fix that.",
|
||||
|
||||
Reference in New Issue
Block a user