On 2/24/2026 2:00 AM, Schimon Jehudah via Python-list wrote:
Greetings.

I am interested at advisory as to how to handle XMPP URI links.

This is how module "urllib" handles this type of URI.


urlparse
--------

from urllib.parse import urlparse

urlparse("xmpp:pubsub.python.i2p?;node=xmpp-python-news")

ParseResult(
   scheme='xmpp',
   netloc='',
   path='pubsub.python.i2p',
   params='',
   query=';node=xmpp-python-news',
   fragment='')

urlparse("xmpp:[email protected]?;node=urn:xmpp:microblog:0;item=xmpp-and-python")

ParseResult(
   scheme='xmpp',
   netloc='',
   path='[email protected]',
   params='',
   query=';node=urn:xmpp:microblog:0;item=xmpp-and-python',
   fragment='')

Hostname (netloc) should be "pubsub.movim.eu" and "python.i2p".

Your example has no netloc. From the Python docs:

"recognizes a netloc only if it is properly introduced by ‘//’. Otherwise the input is presumed to be a relative URL and thus to start with a path component."


parse_qs
--------

Another issue, is not recognizing query parameters.

from urllib.parse import parse_qs

parse_qs("xmpp:[email protected]?;node=urn:xmpp:microblog:0;item=xmpp-and-python")

{'xmpp:[email protected]?;node': ['urn:xmpp:microblog:0;item=xmpp-and-python']}

The query parameters are not recorgnized unless the URI is formed in a similar
fashion to HTTP URI, which is not a valid XMPP URI.

parse_qs("xmpp://[email protected]/?node=urn:xmpp:microblog:0&item=xmpp-and-python")

{'xmpp://[email protected]/?node': ['urn:xmpp:microblog:0'], 'item': 
['xmpp-and-python']}


urllib does not support xmpp:

"The module has been designed to match the internet RFC on Relative Uniform Resource Locators. It supports the following URL schemes: file, ftp, gopher, hdl, http, https, imap, itms-services, mailto, mms, news, nntp, prospero, rsync, rtsp, rtsps, rtspu, sftp, shttp, sip, sips, snews, svn, svn+ssh, telnet, wais, ws, wss."

The docs page is at

https://docs.python.org/3/library/urllib.parse.html#module-urllib.parse

Request
-------

I would appreciate your advisory.


Kind reagrds,
Schimon

--
https://mail.python.org/mailman3//lists/python-list.python.org

Reply via email to