# HG changeset patch # User Goffi # Date 1573213863 -3600 # Node ID 68d423f4fb555da6d72e6e3ac6fe5f572f203563 # Parent 1370323e8f6cfc6faefba0dcc3d7067651744a80 plugin pubsub schema: fixed XML field handling in `sendDataFormItem` diff -r 1370323e8f6c -r 68d423f4fb55 sat/plugins/plugin_exp_pubsub_schema.py --- a/sat/plugins/plugin_exp_pubsub_schema.py Fri Nov 08 11:56:21 2019 +0100 +++ b/sat/plugins/plugin_exp_pubsub_schema.py Fri Nov 08 12:51:03 2019 +0100 @@ -405,15 +405,25 @@ values_list = field.values elif field.ext_type == 'xml': # FIXME: XML elements are not handled correctly, we need to know if we - # actual XML/XHTML, or text to escape + # have actual XML/XHTML, or text to escape for idx, value in enumerate(values_list[:]): - if not isinstance(value, domish.Element): + if isinstance(value, domish.Element): + if (field.value and (value.name != field.value.name + or value.uri != field.value.uri)): + # the element is not the one expected in form, so we create the right element + # to wrap the current value + wrapper_elt = domish.Element((field.value.uri, field.value.name)) + wrapper_elt.addChild(value) + values_list[idx] = wrapper_elt + else: + # we have to convert the value to a domish.Element if field.value and field.value.uri == C.NS_XHTML: div_elt = domish.Element((C.NS_XHTML, 'div')) div_elt.addContent(str(value)) values_list[idx] = div_elt - else: - raise NotImplementedError + else: + # only XHTML fields are handled for now + raise NotImplementedError field.values = values_list