Mercurial > libervia-backend
changeset 3643:30196b9a2b4c
plugin XEP-0277: use `common.uri` to parse comment URIs
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 08 Sep 2021 11:14:53 +0200 (2021-09-08) |
parents | cc3b453670a2 |
children | 062a09705d43 |
files | sat/plugins/plugin_xep_0277.py |
diffstat | 1 files changed, 6 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0277.py Wed Sep 08 11:14:47 2021 +0200 +++ b/sat/plugins/plugin_xep_0277.py Wed Sep 08 11:14:53 2021 +0200 @@ -19,7 +19,6 @@ import time import dateutil import calendar -import urllib.parse from secrets import token_urlsafe from typing import Optional from functools import partial @@ -1006,13 +1005,12 @@ will return(JID(u'sat-pubsub.example.net'), 'urn:xmpp:comments:_af43b363-3259-4b2a-ba4c-1bc33aa87634__urn:xmpp:groupblog:somebody@example.net') @return (tuple[jid.JID, unicode]): service and node """ - parsed_url = urllib.parse.urlparse(node_url, "xmpp") - service = jid.JID(parsed_url.path) - parsed_queries = urllib.parse.parse_qs(parsed_url.query) - node = parsed_queries.get("node", [""])[0] - - if not node: - raise exceptions.DataError("Invalid comments link") + try: + parsed_url = xmpp_uri.parseXMPPUri(node_url) + service = jid.JID(parsed_url["path"]) + node = parsed_url["node"] + except Exception as e: + raise exceptions.DataError(f"Invalid comments link: {e}") return (service, node)