changeset 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 a19161bb3ff7
files src/plugins/plugin_xep_0277.py
diffstat 1 files changed, 6 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/plugin_xep_0277.py	Fri Jan 22 20:24:17 2016 +0100
+++ b/src/plugins/plugin_xep_0277.py	Fri Jan 22 20:24:17 2016 +0100
@@ -619,11 +619,8 @@
         """
         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 @@
         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()))