summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSenthil Kumaran <senthil@uthcode.com>2012-12-24 14:01:13 -0800
committerSenthil Kumaran <senthil@uthcode.com>2012-12-24 14:01:13 -0800
commitbd6667aae3ba362342f121acd8c8f78006049e37 (patch)
treed1f9e98720a490014276ed99d1e54b14c6fd7e83
parent5b187ce700ab17bd41b419e03235a6de96441c4c (diff)
parented30199e7836ff52a101a9ea3a2b31f8455a85a8 (diff)
downloadcpython-git-bd6667aae3ba362342f121acd8c8f78006049e37.tar.gz
Fix issue16713 - tel url parsing with params
-rwxr-xr-xLib/test/test_urlparse.py29
-rw-r--r--Lib/urllib/parse.py2
-rw-r--r--Misc/NEWS3
3 files changed, 33 insertions, 1 deletions
diff --git a/Lib/test/test_urlparse.py b/Lib/test/test_urlparse.py
index e9adaefbd5..378a427bc5 100755
--- a/Lib/test/test_urlparse.py
+++ b/Lib/test/test_urlparse.py
@@ -818,6 +818,35 @@ class UrlParseTestCase(unittest.TestCase):
p2 = urllib.parse.urlsplit('tel:+31641044153')
self.assertEqual(p2.scheme, 'tel')
self.assertEqual(p2.path, '+31641044153')
+ # assert the behavior for urlparse
+ p1 = urllib.parse.urlparse('tel:+31-641044153')
+ self.assertEqual(p1.scheme, 'tel')
+ self.assertEqual(p1.path, '+31-641044153')
+ p2 = urllib.parse.urlparse('tel:+31641044153')
+ self.assertEqual(p2.scheme, 'tel')
+ self.assertEqual(p2.path, '+31641044153')
+
+ def test_telurl_params(self):
+ p1 = urllib.parse.urlparse('tel:123-4;phone-context=+1-650-516')
+ self.assertEqual(p1.scheme, 'tel')
+ self.assertEqual(p1.path, '123-4')
+ self.assertEqual(p1.params, 'phone-context=+1-650-516')
+
+ p1 = urllib.parse.urlparse('tel:+1-201-555-0123')
+ self.assertEqual(p1.scheme, 'tel')
+ self.assertEqual(p1.path, '+1-201-555-0123')
+ self.assertEqual(p1.params, '')
+
+ p1 = urllib.parse.urlparse('tel:7042;phone-context=example.com')
+ self.assertEqual(p1.scheme, 'tel')
+ self.assertEqual(p1.path, '7042')
+ self.assertEqual(p1.params, 'phone-context=example.com')
+
+ p1 = urllib.parse.urlparse('tel:863-1234;phone-context=+1-914-555')
+ self.assertEqual(p1.scheme, 'tel')
+ self.assertEqual(p1.path, '863-1234')
+ self.assertEqual(p1.params, 'phone-context=+1-914-555')
+
def test_main():
support.run_unittest(UrlParseTestCase)
diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py
index 48117593e8..dc75f8f28c 100644
--- a/Lib/urllib/parse.py
+++ b/Lib/urllib/parse.py
@@ -46,7 +46,7 @@ uses_netloc = ['ftp', 'http', 'gopher', 'nntp', 'telnet',
'svn', 'svn+ssh', 'sftp', 'nfs', 'git', 'git+ssh']
uses_params = ['ftp', 'hdl', 'prospero', 'http', 'imap',
'https', 'shttp', 'rtsp', 'rtspu', 'sip', 'sips',
- 'mms', '', 'sftp']
+ 'mms', '', 'sftp', 'tel']
# These are not actually used anymore, but should stay for backwards
# compatibility. (They are undocumented, but have a public-looking name.)
diff --git a/Misc/NEWS b/Misc/NEWS
index 93d6d164e5..c3870ec24a 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -117,6 +117,9 @@ Library
- Issue #16511: Use default IDLE width and height if config param is not valid.
Patch Serhiy Storchaka.
+- Issue #16713: Parsing of 'tel' urls using urlparse separates params from
+ path.
+
- Issue #16443: Add docstrings to regular expression match objects.
Patch by Anton Kasyanov.