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

Papierkorb picture Papierkorb  路  3Comments

relonger picture relonger  路  3Comments

lgphp picture lgphp  路  3Comments

Sija picture Sija  路  3Comments

lbguilherme picture lbguilherme  路  3Comments