Type "help", "copyright", "credits" or "license" for more information.
>>> from urllib.parse import urljoin
>>> urljoin('rtsps://127.0.0.1/foo/bar', 'trackID=1')
'trackID=1'
Type "help", "copyright", "credits" or "license" for more information.
>>> from urllib.parse import urljoin
>>> urljoin('rtsps://127.0.0.1/foo/bar', 'trackID=1')
'rtsps://127.0.0.1/foo/trackID=1'
>>>
--- parse.py.bak 2023-05-16 16:16:01.910634526 +0000
+++ parse.py 2023-05-16 16:17:35.793154580 +0000
@@ -46,17 +46,17 @@
uses_relative = ['', 'ftp', 'http', 'gopher', 'nntp', 'imap',
'wais', 'file', 'https', 'shttp', 'mms',
- 'prospero', 'rtsp', 'rtspu', 'sftp',
+ 'prospero', 'rtsp', 'rtsps', 'rtspu', 'sftp',
'svn', 'svn+ssh', 'ws', 'wss']
uses_netloc = ['', 'ftp', 'http', 'gopher', 'nntp', 'telnet',
'imap', 'wais', 'file', 'mms', 'https', 'shttp',
- 'snews', 'prospero', 'rtsp', 'rtspu', 'rsync',
+ 'snews', 'prospero', 'rtsp', 'rtsps', 'rtspu', 'rsync',
'svn', 'svn+ssh', 'sftp', 'nfs', 'git', 'git+ssh',
'ws', 'wss']
uses_params = ['', 'ftp', 'hdl', 'prospero', 'http', 'imap',
- 'https', 'shttp', 'rtsp', 'rtspu', 'sip', 'sips',
+ 'https', 'shttp', 'rtsp', 'rtsps', 'rtspu', 'sip', 'sips',
'mms', 'sftp', 'tel']
# These are not actually used anymore, but should stay for backwards
@@ -66,7 +66,7 @@
'telnet', 'wais', 'imap', 'snews', 'sip', 'sips']
uses_query = ['', 'http', 'wais', 'imap', 'https', 'shttp', 'mms',
- 'gopher', 'rtsp', 'rtspu', 'sip', 'sips']
+ 'gopher', 'rtsp', 'rtsps', 'rtspu', 'sip', 'sips']
uses_fragment = ['', 'ftp', 'hdl', 'http', 'gopher', 'news',
'nntp', 'wais', 'https', 'shttp', 'snews',
In accordance with
https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml
There are three valid RTSP schemes:
But in
urllib/parse.pyonly two of them are defined:What make impossible to use functions like
urllib.parse.urljoin()uponrtsps://*URLs:Expected result is:
I was able to get the expected behavior by patching
urllib/parsing.py:The issue presents in Python versions:
Linked PRs
urllib/parse.py#104605urllib/parse.py(GH-104605) #105759urllib/parse.py(GH-104605) #105760