Ticket #3623 defect new
twisted.words.xish.domish.Element.addContent doesn't take SerializedXml into account
|Reported by:||ralphm||Owned by:|
Using addContent on an Element when the last child is added by addRawXml, the latter gets improperly escaped.
The problem is best illustrated by the following:
>>> e = domish.Element((None, 'test')) >>> e.addRawXml('<a/>') >>> e.toXml() u'<test><a/></test>' >>> e.addContent('blah') u'<a/>blah' >>> e.toXml() u'<test><a/>blah</test>'
The call to addRawXml adds a SerializedXml object as child. This class derives from unicode to mark that the content should not be escaped. It adds no further functionality. However, addContent checks if the last child of the Element is an instance of one of the StringTypes, which is true also for SerializedXml and happily adds the new content, replacing the SerializedXml object and thus the marking.