Opened 8 years ago

Last modified 8 years ago

#3623 defect new

twisted.words.xish.domish.Element.addContent doesn't take SerializedXml into account

Reported by: ralphm Owned by:
Priority: normal Milestone:
Component: words Keywords:
Cc: Branch:


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()
>>> e.addContent('blah')
>>> e.toXml()

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.

Change History (3)

comment:1 Changed 8 years ago by ralphm

Summary: twisted.words.xish.domish.Element.addElement doesn't take SerializedXml into accounttwisted.words.xish.domish.Element.addContent doesn't take SerializedXml into account

comment:2 Changed 8 years ago by Jean-Paul Calderone

Milestone: Twisted-8.2+1

I can't see any reason this needs to be targeted at 9.0 (8.2+1).

comment:3 Changed 6 years ago by <automation>

Owner: ralphm deleted
Note: See TracTickets for help on using tickets.