Description
In tools/cat/cat.go, file content is placed inside a <content> element and serialized via encoding/xml. If a file contains the literal string ]]> (which closes a CDATA section), the resulting XML is malformed and will fail to parse.
Steps to Reproduce
echo 'some ]]> content' > test.xml
aict cat test.xml --xml | xmllint --noout -
# → parser error
Affected Files
Any file containing ]]>, including:
- XML/HTML source files
- Test fixtures
- Template files
- Generated code
Fix
Split on ]]> occurrences and use adjacent CDATA sections:
<![CDATA[some ]]]]><![CDATA[> content]]>
Or escape the sequence before wrapping in CDATA.
Related
tools/cat/cat.go content serialization
See also: XML spec section 2.7 — CDATA sections may not contain ]]>
Description
In
tools/cat/cat.go, file content is placed inside a<content>element and serialized viaencoding/xml. If a file contains the literal string]]>(which closes a CDATA section), the resulting XML is malformed and will fail to parse.Steps to Reproduce
Affected Files
Any file containing
]]>, including:Fix
Split on
]]>occurrences and use adjacent CDATA sections:Or escape the sequence before wrapping in CDATA.
Related
tools/cat/cat.gocontent serializationSee also: XML spec section 2.7 — CDATA sections may not contain
]]>