Add support for using CDATA for escaping.

CDATA escaping is disabled by default, but may be enabled by setting:

    self.use_cdata = True

Closes issue #114
This commit is contained in:
Lance Stout
2012-07-24 03:25:55 -07:00
parent 3e43b36a9d
commit 9a08dfc7d4
3 changed files with 29 additions and 11 deletions

View File

@@ -1,7 +1,7 @@
from sleekxmpp.test import *
from sleekxmpp.stanza import Message
from sleekxmpp.xmlstream.stanzabase import ET, ElementBase
from sleekxmpp.xmlstream.tostring import tostring, xml_escape
from sleekxmpp.xmlstream.tostring import tostring, escape
class TestToString(SleekTest):
@@ -30,7 +30,7 @@ class TestToString(SleekTest):
def testXMLEscape(self):
"""Test escaping XML special characters."""
original = """<foo bar="baz">'Hi & welcome!'</foo>"""
escaped = xml_escape(original)
escaped = escape(original)
desired = """&lt;foo bar=&quot;baz&quot;&gt;&apos;Hi"""
desired += """ &amp; welcome!&apos;&lt;/foo&gt;"""