Skip to content

cat CDATA output breaks for files containing the ]]> sequence #27

@github-actions

Description

@github-actions

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 ]]>

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions