Currently XML::Builder#cdata happily encodes ]]> within the provided string.
https://play.crystal-lang.org/#/r/90ev
require "xml"
string = XML.build(indent: " ") do |xml|
xml.element("data") { xml.cdata "FOO]]>BAR" }
end
string # => <data><![CDATA[FOO]]>BAR]]></data>
This ultimately causes it to generate invalid XML.
The question is, should it internally handle escaping the end sequence, or leave that up to the user to handle?
I'd say it clearly should.
Most helpful comment
I'd say it clearly should.