From d140752e5bdd5606115cc5596c3b5e9eef909f41 Mon Sep 17 00:00:00 2001 From: "CSREDDY98\\csred" Date: Mon, 12 Jun 2023 16:16:16 -0500 Subject: [PATCH 1/6] gh-105708: 'V' could be case insensitive for IPvFuture hostnames --- Lib/urllib/parse.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py index 82b95adbdc283e..0513f11686c6e1 100644 --- a/Lib/urllib/parse.py +++ b/Lib/urllib/parse.py @@ -544,8 +544,8 @@ def _check_bracketed_netloc(netloc): # Valid bracketed hosts are defined in # https://www.rfc-editor.org/rfc/rfc3986#page-49 and https://url.spec.whatwg.org/ def _check_bracketed_host(hostname): - if hostname.startswith('v'): - if not re.match(r"\Av[a-fA-F0-9]+\..+\z", hostname): + if hostname[0].lower() == 'v': + if not re.match(r"\A[vV][a-fA-F0-9]+\..+\Z", hostname): raise ValueError(f"IPvFuture address is invalid") else: ip = ipaddress.ip_address(hostname) # Throws Value Error if not IPv6 or IPv4 From 529ee9581df06caa946921f1b2a0cc85625b3a6d Mon Sep 17 00:00:00 2001 From: "CSREDDY98\\csred" Date: Mon, 12 Jun 2023 16:59:48 -0500 Subject: [PATCH 2/6] gh-105708: 'V' could be case insensitive for IPvFuture hostnames & checking empty hostnames --- Lib/urllib/parse.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py index 0513f11686c6e1..f939f41c14d2e7 100644 --- a/Lib/urllib/parse.py +++ b/Lib/urllib/parse.py @@ -544,7 +544,7 @@ def _check_bracketed_netloc(netloc): # Valid bracketed hosts are defined in # https://www.rfc-editor.org/rfc/rfc3986#page-49 and https://url.spec.whatwg.org/ def _check_bracketed_host(hostname): - if hostname[0].lower() == 'v': + if len(hostname) > 0 and hostname[0].lower() == 'v': if not re.match(r"\A[vV][a-fA-F0-9]+\..+\Z", hostname): raise ValueError(f"IPvFuture address is invalid") else: From d6e75646983ff5bcc3b2630f00e91d510cb42986 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Mon, 12 Jun 2023 21:31:03 +0000 Subject: [PATCH 3/6] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Library/2023-06-12-21-31-02.gh-issue-105708.5fFwP8.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2023-06-12-21-31-02.gh-issue-105708.5fFwP8.rst diff --git a/Misc/NEWS.d/next/Library/2023-06-12-21-31-02.gh-issue-105708.5fFwP8.rst b/Misc/NEWS.d/next/Library/2023-06-12-21-31-02.gh-issue-105708.5fFwP8.rst new file mode 100644 index 00000000000000..838c5e01805761 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2023-06-12-21-31-02.gh-issue-105708.5fFwP8.rst @@ -0,0 +1 @@ +Changed the urlparser to allow 'v' and 'V' for IPvFuture hostnames as per the standards, From 27f5102be0f30b87092454827cfda232eb82100e Mon Sep 17 00:00:00 2001 From: Senthil Kumaran Date: Sun, 5 Jul 2026 07:12:14 -0700 Subject: [PATCH 4/6] Fix the Merge changing \z to \Z. --- Lib/test/test_urlparse.py | 15 ++++++++++----- Lib/urllib/parse.py | 4 ++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Lib/test/test_urlparse.py b/Lib/test/test_urlparse.py index 8e4da0e0f09919..a5b7966c7780e9 100644 --- a/Lib/test/test_urlparse.py +++ b/Lib/test/test_urlparse.py @@ -1653,15 +1653,20 @@ def test_splitting_bracketed_hosts(self): self.assertEqual(p1.username, 'user') self.assertEqual(p1.path, '/path') self.assertEqual(p1.port, 1234) - p2 = urllib.parse.urlsplit('scheme://user@[0439:23af:2309::fae7%test]/path?query') - self.assertEqual(p2.hostname, '0439:23af:2309::fae7%test') + p2 = urllib.parse.urlsplit('scheme://user@[V6a.ip]:1234/path?query') + self.assertEqual(p2.hostname, 'v6a.ip') self.assertEqual(p2.username, 'user') self.assertEqual(p2.path, '/path') - self.assertIs(p2.port, None) - p3 = urllib.parse.urlsplit('scheme://user@[0439:23af:2309::fae7:1234:192.0.2.146%test]/path?query') - self.assertEqual(p3.hostname, '0439:23af:2309::fae7:1234:192.0.2.146%test') + self.assertEqual(p2.port, 1234) + p3 = urllib.parse.urlsplit('scheme://user@[0439:23af:2309::fae7%test]/path?query') + self.assertEqual(p3.hostname, '0439:23af:2309::fae7%test') self.assertEqual(p3.username, 'user') self.assertEqual(p3.path, '/path') + self.assertIs(p3.port, None) + p4 = urllib.parse.urlsplit('scheme://user@[0439:23af:2309::fae7:1234:192.0.2.146%test]/path?query') + self.assertEqual(p4.hostname, '0439:23af:2309::fae7:1234:192.0.2.146%test') + self.assertEqual(p4.username, 'user') + self.assertEqual(p4.path, '/path') def test_port_casting_failure_message(self): message = "Port could not be cast to integer value as 'oracle'" diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py index f939f41c14d2e7..4247b9a4b07fa3 100644 --- a/Lib/urllib/parse.py +++ b/Lib/urllib/parse.py @@ -544,8 +544,8 @@ def _check_bracketed_netloc(netloc): # Valid bracketed hosts are defined in # https://www.rfc-editor.org/rfc/rfc3986#page-49 and https://url.spec.whatwg.org/ def _check_bracketed_host(hostname): - if len(hostname) > 0 and hostname[0].lower() == 'v': - if not re.match(r"\A[vV][a-fA-F0-9]+\..+\Z", hostname): + if hostname.startswith(('v', 'V')): + if not re.match(r"\A[vV][a-fA-F0-9]+\..+\z", hostname): raise ValueError(f"IPvFuture address is invalid") else: ip = ipaddress.ip_address(hostname) # Throws Value Error if not IPv6 or IPv4 From d90aa844f8cf755967cde0ab263c168ab0e60ec3 Mon Sep 17 00:00:00 2001 From: Senthil Kumaran Date: Sun, 5 Jul 2026 09:00:53 -0700 Subject: [PATCH 5/6] Fixed the News Entry. --- .../next/Library/2023-06-12-21-31-02.gh-issue-105708.5fFwP8.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2023-06-12-21-31-02.gh-issue-105708.5fFwP8.rst b/Misc/NEWS.d/next/Library/2023-06-12-21-31-02.gh-issue-105708.5fFwP8.rst index 838c5e01805761..98c7e02a743d25 100644 --- a/Misc/NEWS.d/next/Library/2023-06-12-21-31-02.gh-issue-105708.5fFwP8.rst +++ b/Misc/NEWS.d/next/Library/2023-06-12-21-31-02.gh-issue-105708.5fFwP8.rst @@ -1 +1 @@ -Changed the urlparser to allow 'v' and 'V' for IPvFuture hostnames as per the standards, +Accept an uppercase V prefix in IPvFuture addresses in :func:`urllib.parse.urlsplit`. \ No newline at end of file From 7d47bab245373ba7d7cefda094a1599d901f79b6 Mon Sep 17 00:00:00 2001 From: Senthil Kumaran Date: Sun, 5 Jul 2026 09:06:32 -0700 Subject: [PATCH 6/6] Fix the lint. --- .../next/Library/2023-06-12-21-31-02.gh-issue-105708.5fFwP8.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2023-06-12-21-31-02.gh-issue-105708.5fFwP8.rst b/Misc/NEWS.d/next/Library/2023-06-12-21-31-02.gh-issue-105708.5fFwP8.rst index 98c7e02a743d25..79289c1f0bd421 100644 --- a/Misc/NEWS.d/next/Library/2023-06-12-21-31-02.gh-issue-105708.5fFwP8.rst +++ b/Misc/NEWS.d/next/Library/2023-06-12-21-31-02.gh-issue-105708.5fFwP8.rst @@ -1 +1 @@ -Accept an uppercase V prefix in IPvFuture addresses in :func:`urllib.parse.urlsplit`. \ No newline at end of file +Accept an uppercase V prefix in IPvFuture addresses in :func:`urllib.parse.urlsplit`.