From f8610ebc4e8f14a3ad2b6b6ad8b0152c0fadaaf7 Mon Sep 17 00:00:00 2001 From: xzf1234 <xzff@hust.edu.cn> Date: Sun, 23 Apr 2023 19:28:25 +0800 Subject: [PATCH] fix field NRESERVED_PAT and function _idna_encode that will cause bugs --- ...SERVED_PAT-and-function-_idna_encode.patch | 34 +++++++++++++++++++ python-urllib3.spec | 9 ++++- 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 backport-Fix-field-NRESERVED_PAT-and-function-_idna_encode.patch diff --git a/backport-Fix-field-NRESERVED_PAT-and-function-_idna_encode.patch b/backport-Fix-field-NRESERVED_PAT-and-function-_idna_encode.patch new file mode 100644 index 0000000..5028dd4 --- /dev/null +++ b/backport-Fix-field-NRESERVED_PAT-and-function-_idna_encode.patch @@ -0,0 +1,34 @@ +From e0b5334d7315e2bc2e9ff852c838acc468e9f296 Mon Sep 17 00:00:00 2001 +From: xzf1244 <xzff@hust.edu.cn> +Date: Sun, 23 Apr 2023 16:33:40 +0800 +Subject: [PATCH] fix field NRESERVED_PAT and function _idna_encode + +--- + src/urllib3/util/url.py | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/urllib3/util/url.py b/src/urllib3/util/url.py +index b667c16..2077592 100644 +--- a/src/urllib3/util/url.py ++++ b/src/urllib3/util/url.py +@@ -50,7 +50,7 @@ _variations = [ + "(?:(?:%(hex)s:){0,6}%(hex)s)?::", + ] + +-UNRESERVED_PAT = r"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._!\-~" ++UNRESERVED_PAT = r"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._\-~" + IPV6_PAT = "(?:" + "|".join([x % _subs for x in _variations]) + ")" + ZONE_ID_PAT = "(?:%25|%)(?:[" + UNRESERVED_PAT + "]|%[a-fA-F0-9]{2})+" + IPV6_ADDRZ_PAT = r"\[" + IPV6_PAT + r"(?:" + ZONE_ID_PAT + r")?\]" +@@ -303,7 +303,7 @@ def _normalize_host(host, scheme): + + + def _idna_encode(name): +- if name and any([ord(x) > 128 for x in name]): ++ if name and any(ord(x) >= 128 for x in name): + try: + import idna + except ImportError: +-- +2.33.1.windows.1 + diff --git a/python-urllib3.spec b/python-urllib3.spec index 1e9ec0b..48a42bd 100644 --- a/python-urllib3.spec +++ b/python-urllib3.spec @@ -3,7 +3,7 @@ Name: python-%{srcname} Version: 1.26.12 -Release: 4 +Release: 5 Summary: Sanity-friendly HTTP client for Python License: MIT URL: https://urllib3.readthedocs.io @@ -17,6 +17,7 @@ Patch6002: backport-fixed-issue-with-port-0-returning-None.patch Patch6003: backport-Fix-socket-timeout-value-when-HTTPConnection-is-reused.patch Patch6004: backport-Remove-Exclamation-mark-character-from-the-unreserved-characters.patch Patch6005: backport-Fix-_idna_encode-handling-of-x80.patch +Patch6006: backport-Fix-field-NRESERVED_PAT-and-function-_idna_encode.patch BuildArch: noarch @@ -82,6 +83,12 @@ PYTHONPATH=%{buildroot}%{python3_sitelib}:%{python3_sitelib} %{__python3} -m pyt %{python3_sitelib}/urllib3-*.egg-info %changelog +* Sun Apr 23 2023 xzf1244 <xzff@hust.edu.com> - 1.26.12-5 +- Type:bugfix +- CVE:NA +- SUG:NA +- DESC:fix field NRESERVED_PAT and function _idna_encode that will cause bugs + * Tue Mar 21 2023 chenhaixing <chenhaixing@huawei.com> - 1.26.12-4 - Type:bugfix - CVE:NA -- Gitee