|
| 1 | +From 141aadcb6e6c1c8ecc850847049002fed4475030 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Ben Kallus < [email protected]> |
| 3 | +Date: Sat, 12 Nov 2022 15:43:33 -0500 |
| 4 | +Subject: [PATCH 1/2] Modify upstream patch to work with CBL-Mariner for |
| 5 | + CVE-2023-24329. Modified by Amrita Kohli < [email protected]> |
| 6 | + |
| 7 | +--- |
| 8 | + Lib/test/test_urlparse.py | 18 ++++++++++++++++++ |
| 9 | + Lib/urllib/parse.py | 2 +- |
| 10 | + 2 files changed, 19 insertions(+), 1 deletion(-) |
| 11 | + |
| 12 | +diff --git a/Lib/test/test_urlparse.py b/Lib/test/test_urlparse.py |
| 13 | +index 31943f3..f42ed9b 100644 |
| 14 | +--- a/Lib/test/test_urlparse.py |
| 15 | ++++ b/Lib/test/test_urlparse.py |
| 16 | +@@ -665,6 +665,24 @@ class UrlParseTestCase(unittest.TestCase): |
| 17 | + with self.assertRaises(ValueError): |
| 18 | + p.port |
| 19 | + |
| 20 | ++ def test_attributes_bad_scheme(self): |
| 21 | ++ """Check handling of invalid schemes.""" |
| 22 | ++ for bytes in (False, True): |
| 23 | ++ for parse in (urllib.parse.urlsplit, urllib.parse.urlparse): |
| 24 | ++ for scheme in (".", "+", "-", "0", "http&", "६http"): |
| 25 | ++ with self.subTest(bytes=bytes, parse=parse, scheme=scheme): |
| 26 | ++ url = scheme + "://www.example.net" |
| 27 | ++ if bytes: |
| 28 | ++ if url.isascii(): |
| 29 | ++ url = url.encode("ascii") |
| 30 | ++ else: |
| 31 | ++ continue |
| 32 | ++ p = parse(url) |
| 33 | ++ if bytes: |
| 34 | ++ self.assertEqual(p.scheme, b"") |
| 35 | ++ else: |
| 36 | ++ self.assertEqual(p.scheme, "") |
| 37 | ++ |
| 38 | + def test_attributes_without_netloc(self): |
| 39 | + # This example is straight from RFC 3261. It looks like it |
| 40 | + # should allow the username, hostname, and port to be filled |
| 41 | +diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py |
| 42 | +index b7965fe..bd59852 100644 |
| 43 | +--- a/Lib/urllib/parse.py |
| 44 | ++++ b/Lib/urllib/parse.py |
| 45 | +@@ -470,7 +470,7 @@ def urlsplit(url, scheme='', allow_fragments=True): |
| 46 | + clear_cache() |
| 47 | + netloc = query = fragment = '' |
| 48 | + i = url.find(':') |
| 49 | +- if i > 0: |
| 50 | ++ if i > 0 and url[0].isascii() and url[0].isalpha(): |
| 51 | + for c in url[:i]: |
| 52 | + if c not in scheme_chars: |
| 53 | + break |
| 54 | +-- |
| 55 | +2.34.1 |
| 56 | + |
| 57 | + |
| 58 | +From de2b58d3b30095440a30fcb72d595b434b351532 Mon Sep 17 00:00:00 2001 |
| 59 | +From: Ben Kallus < [email protected]> |
| 60 | +Date: Sat, 12 Nov 2022 15:46:31 -0500 |
| 61 | +Subject: [PATCH 2/2] gh-99418: Prevent urllib.parse.urlparse from accepting |
| 62 | + schemes that don't begin with an alphabetical ASCII character. |
| 63 | + |
| 64 | +--- |
| 65 | + .../next/Library/2022-11-12-15-45-51.gh-issue-99418.FxfAXS.rst | 2 ++ |
| 66 | + 1 file changed, 2 insertions(+) |
| 67 | + create mode 100644 Misc/NEWS.d/next/Library/2022-11-12-15-45-51.gh-issue-99418.FxfAXS.rst |
| 68 | + |
| 69 | +diff --git a/Misc/NEWS.d/next/Library/2022-11-12-15-45-51.gh-issue-99418.FxfAXS.rst b/Misc/NEWS.d/next/Library/2022-11-12-15-45-51.gh-issue-99418.FxfAXS.rst |
| 70 | +new file mode 100644 |
| 71 | +index 0000000..0a06e7c |
| 72 | +--- /dev/null |
| 73 | ++++ b/Misc/NEWS.d/next/Library/2022-11-12-15-45-51.gh-issue-99418.FxfAXS.rst |
| 74 | +@@ -0,0 +1,2 @@ |
| 75 | ++Fix bug in :func:`urllib.parse.urlparse` that causes URL schemes that begin |
| 76 | ++with a digit, a plus sign, or a minus sign to be parsed incorrectly. |
| 77 | +-- |
| 78 | +2.34.1 |
0 commit comments