Crystal: Should `XML::Builder#cdata` escape nested `]]>`

Created on 5 May 2020  路  1Comment  路  Source: crystal-lang/crystal

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?

bug stdlib

Most helpful comment

I'd say it clearly should.

>All comments

I'd say it clearly should.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

relonger picture relonger  路  3Comments

pbrusco picture pbrusco  路  3Comments

oprypin picture oprypin  路  3Comments

will picture will  路  3Comments

grosser picture grosser  路  3Comments