plugin XEP-0277: moved NS_XHTML namespace to constants + adapted parsing to new behaviour of ElementParser
This commit is contained in:
parent
7066c7775b
commit
dff93495b3
1 changed files with 5 additions and 5 deletions
|
|
@ -43,7 +43,6 @@ import urllib
|
|||
|
||||
NS_MICROBLOG = 'urn:xmpp:microblog:0'
|
||||
NS_ATOM = 'http://www.w3.org/2005/Atom'
|
||||
NS_XHTML = 'http://www.w3.org/1999/xhtml'
|
||||
NS_PUBSUB_EVENT = "{}{}".format(pubsub.NS_PUBSUB, "#event")
|
||||
NS_COMMENT_PREFIX = '{}:comments/'.format(NS_MICROBLOG)
|
||||
|
||||
|
|
@ -173,7 +172,7 @@ class XEP_0277(object):
|
|||
data_elt = elem.firstChildElement()
|
||||
if data_elt is None:
|
||||
raise failure.Failure(exceptions.DataError(u"XHML content not wrapped in a <div/> element, this is not standard !"))
|
||||
if data_elt.uri != NS_XHTML:
|
||||
if data_elt.uri != C.NS_XHTML:
|
||||
raise failure.Failure(exceptions.DataError(_('Content of type XHTML must declare its namespace!')))
|
||||
key = check_conflict(u'{}_xhtml'.format(elem.name))
|
||||
data = data_elt.toXml()
|
||||
|
|
@ -367,10 +366,10 @@ class XEP_0277(object):
|
|||
else:
|
||||
xml_content = data[attr]
|
||||
|
||||
div_elt = xml_tools.ElementParser()(xml_content, namespace=NS_XHTML)
|
||||
if div_elt.name != 'div' or div_elt.uri != NS_XHTML or div_elt.attributes:
|
||||
div_elt = xml_tools.ElementParser()(xml_content, namespace=C.NS_XHTML)
|
||||
if div_elt.name != 'div' or div_elt.uri != C.NS_XHTML or div_elt.attributes:
|
||||
# we need a wrapping <div/> at the top with XHTML namespace
|
||||
wrap_div_elt = domish.Element((NS_XHTML, 'div'))
|
||||
wrap_div_elt = domish.Element((C.NS_XHTML, 'div'))
|
||||
wrap_div_elt.addChild(div_elt)
|
||||
div_elt = wrap_div_elt
|
||||
elem.addChild(div_elt)
|
||||
|
|
|
|||
Loading…
Reference in a new issue