Mercurial > libervia-backend
comparison src/plugins/plugin_xep_0277.py @ 1823:1424cc6f8e98
plugin XEP-0277: fixed encoding issue, specially with parseCommentUrl, which could lead to the impossibility to find comments node
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 22 Jan 2016 20:24:17 +0100 |
parents | aaf034bc6f7a |
children | 6079752ffeae |
comparison
equal
deleted
inserted
replaced
1822:aaf034bc6f7a | 1823:1424cc6f8e98 |
---|---|
617 will return (JID(u'sat-pubsub.libervia.org'), 'urn:xmpp:comments:_c5c4a142-2279-4b2a-ba4c-1bc33aa87634__urn:xmpp:groupblog:souliane@libervia.org') | 617 will return (JID(u'sat-pubsub.libervia.org'), 'urn:xmpp:comments:_c5c4a142-2279-4b2a-ba4c-1bc33aa87634__urn:xmpp:groupblog:souliane@libervia.org') |
618 @return: a tuple (JID, str) | 618 @return: a tuple (JID, str) |
619 """ | 619 """ |
620 parsed_url = urlparse.urlparse(node_url, 'xmpp') | 620 parsed_url = urlparse.urlparse(node_url, 'xmpp') |
621 service = jid.JID(parsed_url.path) | 621 service = jid.JID(parsed_url.path) |
622 queries = parsed_url.query.split(';') | 622 parsed_queries = urlparse.parse_qs(parsed_url.query.encode('utf-8')) |
623 parsed_queries = dict() | 623 node = parsed_queries.get('node', [''])[0].decode('utf-8') |
624 for query in queries: | |
625 parsed_queries.update(urlparse.parse_qs(query)) | |
626 node = parsed_queries.get('node', [''])[0] | |
627 | 624 |
628 if not node: | 625 if not node: |
629 raise failure.Failure(exceptions.DataError('Invalid comments link')) | 626 raise failure.Failure(exceptions.DataError('Invalid comments link')) |
630 | 627 |
631 return (service, node) | 628 return (service, node) |
954 feed_elt = domish.Element((NS_ATOM, 'feed')) | 951 feed_elt = domish.Element((NS_ATOM, 'feed')) |
955 title = D_(u"{user}'s blogposts").format(user=service_jid.user) | 952 title = D_(u"{user}'s blogposts").format(user=service_jid.user) |
956 feed_elt.addElement('title', content=title) | 953 feed_elt.addElement('title', content=title) |
957 link_feed_elt = feed_elt.addElement('link') | 954 link_feed_elt = feed_elt.addElement('link') |
958 link_feed_elt['href'] = 'http://{host}/blog/{user}/atom.xml'.format( | 955 link_feed_elt['href'] = 'http://{host}/blog/{user}/atom.xml'.format( |
959 host=urllib.quote(service_jid.host,''), | 956 host=urllib.quote(service_jid.host.encode('utf-8'),''), |
960 user=urllib.quote(service_jid.user,'')) | 957 user=urllib.quote(service_jid.user.encode('utf-8'),'')) |
961 link_feed_elt['rel'] = 'self' | 958 link_feed_elt['rel'] = 'self' |
962 link_blog_elt = feed_elt.addElement('link') | 959 link_blog_elt = feed_elt.addElement('link') |
963 link_blog_elt['href'] = 'http://{host}/blog/{user}'.format( | 960 link_blog_elt['href'] = 'http://{host}/blog/{user}'.format( |
964 host=urllib.quote(service_jid.host,''), | 961 host=urllib.quote(service_jid.host.encode('utf-8'),''), |
965 user=urllib.quote(service_jid.user,'')) | 962 user=urllib.quote(service_jid.user.encode('utf-8'),'')) |
966 feed_elt.addElement('id', content=node) | 963 feed_elt.addElement('id', content=node) |
967 feed_elt.addElement('updated', rfc3339.timestamp_from_tf(rfc3339.tf_utc())) | 964 feed_elt.addElement('updated', rfc3339.timestamp_from_tf(rfc3339.tf_utc())) |
968 | 965 |
969 # FIXME: no cleaning is done here | 966 # FIXME: no cleaning is done here |
970 # FIXME: no check is done neither, we have to be sure that we get microblogs | 967 # FIXME: no check is done neither, we have to be sure that we get microblogs |