From 9cc2a923fa7215a685b0913ba76b78314d398662 Mon Sep 17 00:00:00 2001 From: Goffi Date: Tue, 1 Dec 2015 13:55:48 +0100 Subject: [PATCH] plugin XEP-0277: accept several elements, there is a standard issue so for now it's the most flexible behaviour --- src/plugins/plugin_xep_0277.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) 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 <title/> 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)