From f676748a052cacdf9963aa840bfa6107275d163e Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Fri, 16 Sep 2016 14:43:58 +0300 Subject: [PATCH] Issue #25895: Enable WebSocket URL schemes in urllib.parse.urljoin Patch by Gergely Imreh and Markus Holtermann. --- Doc/library/urllib.parse.rst | 2 +- Lib/test/test_urlparse.py | 2 ++ Lib/urllib/parse.py | 5 +++-- Misc/NEWS | 3 +++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Doc/library/urllib.parse.rst b/Doc/library/urllib.parse.rst index c6de2303c6c..007e4da6aa9 100644 --- a/Doc/library/urllib.parse.rst +++ b/Doc/library/urllib.parse.rst @@ -25,7 +25,7 @@ Resource Locators. It supports the following URL schemes: ``file``, ``ftp``, ``gopher``, ``hdl``, ``http``, ``https``, ``imap``, ``mailto``, ``mms``, ``news``, ``nntp``, ``prospero``, ``rsync``, ``rtsp``, ``rtspu``, ``sftp``, ``shttp``, ``sip``, ``sips``, ``snews``, ``svn``, ``svn+ssh``, ``telnet``, -``wais``. +``wais``, ``ws``, ``wss``. The :mod:`urllib.parse` module defines functions that fall into two broad categories: URL parsing and URL quoting. These are covered in detail in diff --git a/Lib/test/test_urlparse.py b/Lib/test/test_urlparse.py index 829997fd6a2..71abc147a6f 100644 --- a/Lib/test/test_urlparse.py +++ b/Lib/test/test_urlparse.py @@ -425,6 +425,8 @@ class UrlParseTestCase(unittest.TestCase): self.checkJoin('', 'http://a/./g', 'http://a/./g') self.checkJoin('svn://pathtorepo/dir1', 'dir2', 'svn://pathtorepo/dir2') self.checkJoin('svn+ssh://pathtorepo/dir1', 'dir2', 'svn+ssh://pathtorepo/dir2') + self.checkJoin('ws://a/b','g','ws://a/g') + self.checkJoin('wss://a/b','g','wss://a/g') # XXX: The following tests are no longer compatible with RFC3986 # self.checkJoin(SIMPLE_BASE, '../../../g','http://a/../g') diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py index 4d7fcec94b1..566fbf71888 100644 --- a/Lib/urllib/parse.py +++ b/Lib/urllib/parse.py @@ -42,11 +42,12 @@ __all__ = ["urlparse", "urlunparse", "urljoin", "urldefrag", uses_relative = ['ftp', 'http', 'gopher', 'nntp', 'imap', 'wais', 'file', 'https', 'shttp', 'mms', 'prospero', 'rtsp', 'rtspu', '', 'sftp', - 'svn', 'svn+ssh'] + 'svn', 'svn+ssh', 'ws', 'wss'] uses_netloc = ['ftp', 'http', 'gopher', 'nntp', 'telnet', 'imap', 'wais', 'file', 'mms', 'https', 'shttp', 'snews', 'prospero', 'rtsp', 'rtspu', 'rsync', '', - 'svn', 'svn+ssh', 'sftp', 'nfs', 'git', 'git+ssh'] + 'svn', 'svn+ssh', 'sftp', 'nfs', 'git', 'git+ssh', + 'ws', 'wss'] uses_params = ['ftp', 'hdl', 'prospero', 'http', 'imap', 'https', 'shttp', 'rtsp', 'rtspu', 'sip', 'sips', 'mms', '', 'sftp', 'tel'] diff --git a/Misc/NEWS b/Misc/NEWS index 9e61ef3d35b..3c1918357bc 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -71,6 +71,9 @@ Core and Builtins Library ------- +- Issue #25895: Enable WebSocket URL schemes in urllib.parse.urljoin. + Patch by Gergely Imreh and Markus Holtermann. + - Issue #27599: Fixed buffer overrun in binascii.b2a_qp() and binascii.a2b_qp(). - Issue #19003:m email.generator now replaces only \r and/or \n line