plugin XEP-0277: use common.uri to parse comment URIs
This commit is contained in:
parent
adad4494c3
commit
dae3308751
1 changed files with 6 additions and 8 deletions
|
|
@ -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 @@ class XEP_0277(object):
|
|||
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)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue