Mercurial > libervia-backend
comparison src/plugins/plugin_xep_0277.py @ 1709:c47ba491a85a
plugin XEP-0277: raise a failure if XHTML content is not wrapped in a <div/>
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 01 Dec 2015 13:55:48 +0100 |
parents | 6d6eae490681 |
children | e5b569d0c2e7 |
comparison
equal
deleted
inserted
replaced
1708:6d6eae490681 | 1709:c47ba491a85a |
---|---|
171 def parseElement(elem): | 171 def parseElement(elem): |
172 """Parse title/content elements and fill microblog_data accordingly""" | 172 """Parse title/content elements and fill microblog_data accordingly""" |
173 type_ = elem.getAttribute('type') | 173 type_ = elem.getAttribute('type') |
174 if type_ == 'xhtml': | 174 if type_ == 'xhtml': |
175 data_elt = elem.firstChildElement() | 175 data_elt = elem.firstChildElement() |
176 if data_elt is None: | |
177 raise failure.Failure(exceptions.DataError(u"XHML content not wrapped in a <div/> element, this is not standard !")) | |
176 if data_elt.uri != NS_XHTML: | 178 if data_elt.uri != NS_XHTML: |
177 raise failure.Failure(exceptions.DataError(_('Content of type XHTML must declare its namespace!'))) | 179 raise failure.Failure(exceptions.DataError(_('Content of type XHTML must declare its namespace!'))) |
178 key = check_conflict(u'{}_xhtml'.format(elem.name)) | 180 key = check_conflict(u'{}_xhtml'.format(elem.name)) |
179 data = data_elt.toXml() | 181 data = data_elt.toXml() |
180 microblog_data[key] = yield self.host.plugins["TEXT-SYNTAXES"].clean_xhtml(data) | 182 microblog_data[key] = yield self.host.plugins["TEXT-SYNTAXES"].clean_xhtml(data) |