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.
This commit is contained in:
parent
d1e77c78ee
commit
26b64ca9fc
1 changed files with 4 additions and 4 deletions
|
@ -40,13 +40,13 @@ def _add_text_elm(entry, data, name):
|
||||||
elif type_ == 'CDATA':
|
elif type_ == 'CDATA':
|
||||||
elm.text = etree.CDATA(
|
elm.text = etree.CDATA(
|
||||||
data.get(name))
|
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
|
# 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(
|
elm.append(etree.fromstring(
|
||||||
data[name]))
|
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
|
# Everything else should be included base64 encoded
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError(
|
raise NotImplementedError(
|
||||||
|
|
Loading…
Reference in a new issue