Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit eaaec27

Browse files
committed
Fix for Issue4962, issue4675.
1 parent 7f6b4f8 commit eaaec27

3 files changed

Lines changed: 21 additions & 2 deletions

File tree

Lib/test/test_urllib.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,21 @@ def test_quoting(self):
830830
"url2pathname() failed; %s != %s" %
831831
(expect, result))
832832

833+
class Utility_Tests(unittest.TestCase):
834+
"""Testcase to test the various utility functions in the urllib."""
835+
836+
def test_splitpasswd(self):
837+
"""Some of password examples are not sensible, but it is added to
838+
confirming to RFC2617 and addressing issue4675.
839+
"""
840+
self.assertEqual(('user', 'ab'),urllib.parse.splitpasswd('user:ab'))
841+
self.assertEqual(('user', 'a\nb'),urllib.parse.splitpasswd('user:a\nb'))
842+
self.assertEqual(('user', 'a\tb'),urllib.parse.splitpasswd('user:a\tb'))
843+
self.assertEqual(('user', 'a\rb'),urllib.parse.splitpasswd('user:a\rb'))
844+
self.assertEqual(('user', 'a\fb'),urllib.parse.splitpasswd('user:a\fb'))
845+
self.assertEqual(('user', 'a\vb'),urllib.parse.splitpasswd('user:a\vb'))
846+
self.assertEqual(('user', 'a:b'),urllib.parse.splitpasswd('user:a:b'))
847+
833848
# Just commented them out.
834849
# Can't really tell why keep failing in windows and sparc.
835850
# Everywhere else they work ok, but on those machines, someteimes
@@ -920,6 +935,7 @@ def test_main():
920935
UnquotingTests,
921936
urlencode_Tests,
922937
Pathname_Tests,
938+
Utility_Tests,
923939
#FTPWrapperTests,
924940
)
925941

Lib/test/test_urlparse.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ def test_roundtrips(self):
9797
'', '', ''),
9898
('mms', 'wms.sys.hinet.net', '/cts/Drama/09006251100.asf',
9999
'', '')),
100+
('nfs://server/path/to/file.txt',
101+
('nfs', 'server', '/path/to/file.txt', '', '', ''),
102+
('nfs', 'server', '/path/to/file.txt', '', '')),
100103
('svn+ssh://svn.zope.org/repos/main/ZConfig/trunk/',
101104
('svn+ssh', 'svn.zope.org', '/repos/main/ZConfig/trunk/',
102105
'', '', ''),

Lib/urllib/parse.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
uses_netloc = ['ftp', 'http', 'gopher', 'nntp', 'telnet',
2020
'imap', 'wais', 'file', 'mms', 'https', 'shttp',
2121
'snews', 'prospero', 'rtsp', 'rtspu', 'rsync', '',
22-
'svn', 'svn+ssh', 'sftp']
22+
'svn', 'svn+ssh', 'sftp','nfs']
2323
non_hierarchical = ['gopher', 'hdl', 'mailto', 'news',
2424
'telnet', 'wais', 'imap', 'snews', 'sip', 'sips']
2525
uses_params = ['ftp', 'hdl', 'prospero', 'http', 'imap',
@@ -645,7 +645,7 @@ def splitpasswd(user):
645645
global _passwdprog
646646
if _passwdprog is None:
647647
import re
648-
_passwdprog = re.compile('^([^:]*):(.*)$')
648+
_passwdprog = re.compile('^([^:]*):(.*)$',re.S)
649649

650650
match = _passwdprog.match(user)
651651
if match: return match.group(1, 2)

0 commit comments

Comments
 (0)