From 26b64ca9fcac6b8e53132698b9fe0d4971993a4d Mon Sep 17 00:00:00 2001 From: Lars Kiesow Date: Sat, 25 Jan 2020 02:11:39 +0100 Subject: [PATCH] Properly Parse text/xml This patch fixes the problem that content with the MIME type `text/xml` is accidentally treated as text rather than as XML. --- feedgen/entry.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/feedgen/entry.py b/feedgen/entry.py index e90cbfd..8617bb2 100644 --- a/feedgen/entry.py +++ b/feedgen/entry.py @@ -40,13 +40,13 @@ def _add_text_elm(entry, data, name): elif type_ == 'CDATA': elm.text = etree.CDATA( data.get(name)) - # Emed the text in escaped form - elif not type_ or type_.startswith('text') or type_ == 'html': - elm.text = data.get(name) # Parse XML and embed it - elif type_.endswith('/xml') or type_.endswith('+xml'): + elif type_ and (type_.endswith('/xml') or type_.endswith('+xml')): elm.append(etree.fromstring( data[name])) + # Embed the text in escaped form + elif not type_ or type_.startswith('text') or type_ == 'html': + elm.text = data.get(name) # Everything else should be included base64 encoded else: raise NotImplementedError(