From 333a43e8240aed8b9f11b38ac6c6f5791cfb8a52 Mon Sep 17 00:00:00 2001 From: Goffi Date: Fri, 22 Jan 2016 20:24:17 +0100 Subject: [PATCH] plugin XEP-0277: fixed encoding issue, specially with parseCommentUrl, which could lead to the impossibility to find comments node --- src/plugins/plugin_xep_0277.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/plugins/plugin_xep_0277.py b/src/plugins/plugin_xep_0277.py index c39ac07c..9d596adb 100755 --- a/src/plugins/plugin_xep_0277.py +++ b/src/plugins/plugin_xep_0277.py @@ -619,11 +619,8 @@ class XEP_0277(object): """ parsed_url = urlparse.urlparse(node_url, 'xmpp') service = jid.JID(parsed_url.path) - queries = parsed_url.query.split(';') - parsed_queries = dict() - for query in queries: - parsed_queries.update(urlparse.parse_qs(query)) - node = parsed_queries.get('node', [''])[0] + parsed_queries = urlparse.parse_qs(parsed_url.query.encode('utf-8')) + node = parsed_queries.get('node', [''])[0].decode('utf-8') if not node: raise failure.Failure(exceptions.DataError('Invalid comments link')) @@ -956,13 +953,13 @@ class XEP_0277(object): feed_elt.addElement('title', content=title) link_feed_elt = feed_elt.addElement('link') link_feed_elt['href'] = 'http://{host}/blog/{user}/atom.xml'.format( - host=urllib.quote(service_jid.host,''), - user=urllib.quote(service_jid.user,'')) + host=urllib.quote(service_jid.host.encode('utf-8'),''), + user=urllib.quote(service_jid.user.encode('utf-8'),'')) link_feed_elt['rel'] = 'self' link_blog_elt = feed_elt.addElement('link') link_blog_elt['href'] = 'http://{host}/blog/{user}'.format( - host=urllib.quote(service_jid.host,''), - user=urllib.quote(service_jid.user,'')) + host=urllib.quote(service_jid.host.encode('utf-8'),''), + user=urllib.quote(service_jid.user.encode('utf-8'),'')) feed_elt.addElement('id', content=node) feed_elt.addElement('updated', rfc3339.timestamp_from_tf(rfc3339.tf_utc()))