Fix atom content type CDATA

This commit is contained in:
Russel Mahmud 2016-03-03 14:44:56 +06:00
parent 290045ac49
commit 5724c569b1
2 changed files with 13 additions and 1 deletions

View file

@ -104,7 +104,7 @@ class FeedEntry(object):
xmlns="http://www.w3.org/1999/xhtml">%s</div>''' % \ xmlns="http://www.w3.org/1999/xhtml">%s</div>''' % \
self.__atom_content.get('content'))) self.__atom_content.get('content')))
elif type == 'CDATA': elif type == 'CDATA':
content.text = etree.CDATA(self.__atom_content) content.text = etree.CDATA(self.__atom_content.get('content'))
# Emed the text in escaped form # Emed the text in escaped form
elif not type or type.startswith('text') or type == 'html': elif not type or type.startswith('text') or type == 'html':
content.text = self.__atom_content.get('content') content.text = self.__atom_content.get('content')

View file

@ -92,3 +92,15 @@ class TestSequenceFunctions(unittest.TestCase):
result = fg.rss_str() result = fg.rss_str()
assert b'domain="http://www.somedomain.com/category"' in result assert b'domain="http://www.somedomain.com/category"' in result
def test_content_cdata_type(self):
fg = FeedGenerator()
fg.title('some title')
fg.id('http://lernfunk.de/media/654322/1')
fe = fg.add_entry()
fe.id('http://lernfunk.de/media/654322/1')
fe.title('some title')
fe.content('content', type='CDATA')
result = fg.atom_str()
assert b'<content type="CDATA"><![CDATA[content]]></content>' in result