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

Skip to content

Commit ed30199

Browse files
committed
Fix issue16713 - tel url parsing with params
1 parent 08bab07 commit ed30199

3 files changed

Lines changed: 33 additions & 1 deletion

File tree

Lib/test/test_urlparse.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,35 @@ def test_issue14072(self):
818818
p2 = urllib.parse.urlsplit('tel:+31641044153')
819819
self.assertEqual(p2.scheme, 'tel')
820820
self.assertEqual(p2.path, '+31641044153')
821+
# assert the behavior for urlparse
822+
p1 = urllib.parse.urlparse('tel:+31-641044153')
823+
self.assertEqual(p1.scheme, 'tel')
824+
self.assertEqual(p1.path, '+31-641044153')
825+
p2 = urllib.parse.urlparse('tel:+31641044153')
826+
self.assertEqual(p2.scheme, 'tel')
827+
self.assertEqual(p2.path, '+31641044153')
828+
829+
def test_telurl_params(self):
830+
p1 = urllib.parse.urlparse('tel:123-4;phone-context=+1-650-516')
831+
self.assertEqual(p1.scheme, 'tel')
832+
self.assertEqual(p1.path, '123-4')
833+
self.assertEqual(p1.params, 'phone-context=+1-650-516')
834+
835+
p1 = urllib.parse.urlparse('tel:+1-201-555-0123')
836+
self.assertEqual(p1.scheme, 'tel')
837+
self.assertEqual(p1.path, '+1-201-555-0123')
838+
self.assertEqual(p1.params, '')
839+
840+
p1 = urllib.parse.urlparse('tel:7042;phone-context=example.com')
841+
self.assertEqual(p1.scheme, 'tel')
842+
self.assertEqual(p1.path, '7042')
843+
self.assertEqual(p1.params, 'phone-context=example.com')
844+
845+
p1 = urllib.parse.urlparse('tel:863-1234;phone-context=+1-914-555')
846+
self.assertEqual(p1.scheme, 'tel')
847+
self.assertEqual(p1.path, '863-1234')
848+
self.assertEqual(p1.params, 'phone-context=+1-914-555')
849+
821850

822851
def test_main():
823852
support.run_unittest(UrlParseTestCase)

Lib/urllib/parse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
'svn', 'svn+ssh', 'sftp', 'nfs', 'git', 'git+ssh']
4747
uses_params = ['ftp', 'hdl', 'prospero', 'http', 'imap',
4848
'https', 'shttp', 'rtsp', 'rtspu', 'sip', 'sips',
49-
'mms', '', 'sftp']
49+
'mms', '', 'sftp', 'tel']
5050

5151
# These are not actually used anymore, but should stay for backwards
5252
# compatibility. (They are undocumented, but have a public-looking name.)

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ Library
182182
- Issue #16511: Use default IDLE width and height if config param is not valid.
183183
Patch Serhiy Storchaka.
184184

185+
- Issue #16713: Parsing of 'tel' urls using urlparse separates params from
186+
path.
187+
185188
- Issue #16443: Add docstrings to regular expression match objects.
186189
Patch by Anton Kasyanov.
187190

0 commit comments

Comments
 (0)