Mercurial > libervia-backend
diff sat/plugins/plugin_xep_0277.py @ 3661:cbb988a6f507
merge bookmark `@`
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 08 Sep 2021 11:20:37 +0200 |
parents | d390ff50af0f 30196b9a2b4c |
children | 68f2a9c171d1 |
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0277.py Wed Sep 01 15:25:02 2021 +0200 +++ b/sat/plugins/plugin_xep_0277.py Wed Sep 08 11:20:37 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 @@ -1032,13 +1031,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)