diff --git a/src/plugins/plugin_xep_0277.py b/src/plugins/plugin_xep_0277.py index df85fbae..5a40cc2f 100755 --- a/src/plugins/plugin_xep_0277.py +++ b/src/plugins/plugin_xep_0277.py @@ -207,14 +207,26 @@ class XEP_0277(object): microblog_data['atom_id'] = unicode(id_elt) # title/content(s) - try: - title_elt = entry_elt.elements(NS_ATOM, 'title').next() - except StopIteration: + + # FIXME: ATOM and XEP-0277 only allow 1 element + # but in the wild we have some blogs with several ones + # so we don't respect the standard for now (it doesn't break + # anything anyway), and we'll find a better option later + # try: + # title_elt = entry_elt.elements(NS_ATOM, 'title').next() + # except StopIteration: + # msg = u'No atom title found in the pubsub item {}'.format(id_) + # raise failure.Failure(exceptions.DataError(msg)) + title_elts = list(entry_elt.elements(NS_ATOM, 'title')) + if not title_elts: msg = u'No atom title found in the pubsub item {}'.format(id_) raise failure.Failure(exceptions.DataError(msg)) + for title_elt in title_elts: + yield parseElement(title_elt) - yield parseElement(title_elt) - + # FIXME: as for <title/>, Atom only authorise at most 1 content + # but XEP-0277 allows several ones. So for no we handle as + # if more than one can be present for content_elt in entry_elt.elements(NS_ATOM, 'content'): yield parseElement(content_elt)