You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My team is interested in generating VAST 3 (video ad standard template) XML using the xml package. Unfortunately the VAST 3 spec specifies:
" All URIs or any other free text fields containing potentially dangerous characters contained in the VAST document should be wrapped in CDATA blocks." http://www.iab.net/media/file/VASTv3.0.pdf p. 23
Currently fields labeled with the xml ",chardata" tag are only output as URL encoded XML. We have a workaround using the Marshaler interface, but it's verbose and bug prone. i.e:
// CharData is a string that should be cdata-wrapped according to the VAST 3 spec.
type CharData string
// MarshalXML implements the xml.Marshaler interface for generating XML.
func (cd CharData) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
return e.EncodeElement(struct {
S string `xml:",innerxml"`
}{
S: "<![CDATA[" + string(cd) + "]]>",
}, start)
}
There should be a first-class way to output CDATA escaped data in the xml package, perhaps with the addition of a ",cdata" tag.
The text was updated successfully, but these errors were encountered:
As far as addressing VAST 3 is concerned, does it make more sense to have a ,cdata field or to have a method call on *xml.Encoder that says "use CDATA always"?
rsc
changed the title
encoding/xml: Add CDATA-wrapper support to xml.Marshal
encoding/xml: allow Marshal to use CDATA
Nov 5, 2015
Followup to CL 16047.
For #12963.
Change-Id: I596cd5109b25a4079b966427411860fde8b9b54a
Reviewed-on: https://go-review.googlesource.com/17232
Reviewed-by: David Crawshaw <crawshaw@golang.org>
My team is interested in generating VAST 3 (video ad standard template) XML using the xml package. Unfortunately the VAST 3 spec specifies:
" All URIs or any other free text fields containing potentially dangerous characters contained in the VAST document should be wrapped in CDATA blocks." http://www.iab.net/media/file/VASTv3.0.pdf p. 23
Currently fields labeled with the xml ",chardata" tag are only output as URL encoded XML. We have a workaround using the Marshaler interface, but it's verbose and bug prone. i.e:
There should be a first-class way to output CDATA escaped data in the xml package, perhaps with the addition of a ",cdata" tag.
The text was updated successfully, but these errors were encountered: