mirror of
https://github.com/mikefarah/yq.git
synced 2024-12-19 20:19:04 +00:00
Fixing sef fault on bad XML #1888
This commit is contained in:
parent
1c3d551060
commit
d474bb8ba4
@ -299,6 +299,10 @@ func (dec *xmlDecoder) decodeXML(root *xmlNode) error {
|
||||
log.Debug("chardata [%v] for %v", elem.n.Data, elem.label)
|
||||
}
|
||||
case xml.EndElement:
|
||||
if elem == nil {
|
||||
log.Debug("no element, probably bad xml")
|
||||
continue
|
||||
}
|
||||
log.Debug("end element %v", elem.label)
|
||||
elem.state = "finished"
|
||||
// And add it to its parent list
|
||||
|
@ -263,6 +263,12 @@ const expectedXmlWithProcInstAndDirectives = `<?xml version="1.0"?>
|
||||
`
|
||||
|
||||
var xmlScenarios = []formatScenario{
|
||||
{
|
||||
skipDoc: true,
|
||||
description: "bad xml",
|
||||
input: `<?xml version="1.0" encoding="UTF-8"?></Child></Root>`,
|
||||
expected: "+p_xml: version=\"1.0\" encoding=\"UTF-8\"\n",
|
||||
},
|
||||
{
|
||||
skipDoc: true,
|
||||
input: " <root>value<!-- comment--> </root>",
|
||||
|
Loading…
Reference in New Issue
Block a user