From 7d7df0b1b99f9d45ec08ebcf8357ecad0dc398b9 Mon Sep 17 00:00:00 2001 From: Gergely Imreh Date: Thu, 17 Dec 2015 13:51:50 +0800 Subject: [PATCH 1/1] urllib.parse: enable WebSocket URL schemes to be correctly handled Based on the WebSockets Protocol standards defined in RFC6455. Signed-off-by: Gergely Imreh --- Lib/test/test_urlparse.py | 2 ++ Lib/urllib/parse.py | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_urlparse.py b/Lib/test/test_urlparse.py index fcf5082..03e545a 100644 --- a/Lib/test/test_urlparse.py +++ b/Lib/test/test_urlparse.py @@ -374,6 +374,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 5e2155c..7ad6621 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'] -- 2.5.0