plugin XEP_0277: check for XHTML namespace and decapsulate the content from the main div container
This commit is contained in:
parent
c2e4e9f8f9
commit
a3e2beeeae
1 changed files with 12 additions and 2 deletions
|
|
@ -121,8 +121,8 @@ class XEP_0277(object):
|
|||
except KeyError:
|
||||
content_type = 'text'
|
||||
if content_type == 'xhtml':
|
||||
# TODO: proper check of body namespace
|
||||
microblog_data['%s_xhtml' % key] = yield self.host.plugins["TEXT-SYNTAXES"].clean_xhtml(attr.text)
|
||||
text = self.__decapsulateExtraNS(attr.text)
|
||||
microblog_data['%s_xhtml' % key] = yield self.host.plugins["TEXT-SYNTAXES"].clean_xhtml(text)
|
||||
else:
|
||||
microblog_data[key] = attr.text
|
||||
if key not in microblog_data and ('%s_xhtml' % key) in microblog_data:
|
||||
|
|
@ -173,6 +173,16 @@ class XEP_0277(object):
|
|||
|
||||
defer.returnValue(microblog_data)
|
||||
|
||||
def __decapsulateExtraNS(self, text):
|
||||
"""Check for XHTML namespace and decapsulate the content so the user
|
||||
who wants to modify an entry will see the text that he entered. Also
|
||||
this avoids successive encapsulation with a new <div>...</div> at
|
||||
each modification (encapsulation is done in self.data2entry)"""
|
||||
elt = ElementParser()(text)
|
||||
if elt.uri != NS_XHTML:
|
||||
raise exceptions.DataError(_('Content of type XHTML must declare its namespace!'))
|
||||
return elt.firstChildElement().toXml()
|
||||
|
||||
def microblogCB(self, itemsEvent, profile):
|
||||
d = defer.Deferred()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue