!59 [sync] PR-58: backport some patches

From: @openeuler-sync-bot 
Reviewed-by: @seuzw 
Signed-off-by: @seuzw
This commit is contained in:
openeuler-ci-bot 2023-01-30 09:32:29 +00:00 committed by Gitee
commit e6e2c12487
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 128 additions and 1 deletions

View File

@ -0,0 +1,25 @@
From f1d40fd07f7b5d9cf846a18fb5a920b4be07dfc5 Mon Sep 17 00:00:00 2001
From: Hasan Ramezani <hasan.r67@gmail.com>
Date: Thu, 20 Jan 2022 15:56:02 +0100
Subject: [PATCH] [1.26] Add server_hostname to SSL_KEYWORDS
Conflict:no add testcode
Reference:https://github.com/urllib3/urllib3/commit/f1d40fd07f7b5d9cf846a18fb5a920b4be07dfc5
---
src/urllib3/poolmanager.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/urllib3/poolmanager.py b/src/urllib3/poolmanager.py
index 3a31a28..ca4ec34 100644
--- a/src/urllib3/poolmanager.py
+++ b/src/urllib3/poolmanager.py
@@ -34,6 +34,7 @@ SSL_KEYWORDS = (
"ca_cert_dir",
"ssl_context",
"key_password",
+ "server_hostname",
)
# All known keyword arguments that could be provided to the pool manager, its
--
2.27.0

View File

@ -0,0 +1,47 @@
From 7b6049c4d7551c0a3d04e213b853ef33b8ed1cd9 Mon Sep 17 00:00:00 2001
From: Bastian Venthur <venthur@debian.org>
Date: Fri, 9 Dec 2022 21:47:14 +0100
Subject: [PATCH] fixed issue with port "0" returning None
Conflict:adapt:
1.no change changelog/2850.bugfix.rst
2.The content of "@@" is adapted
Reference:https://github.com/urllib3/urllib3/pull/2849
---
src/urllib3/util/url.py | 2 +-
test/test_util.py | 7 +++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/urllib3/util/url.py b/src/urllib3/util/url.py
index 6793de3..701ad75 100644
--- a/src/urllib3/util/url.py
+++ b/src/urllib3/util/url.py
@@ -63,7 +63,7 @@ IPV6_ADDRZ_RE = re.compile("^" + IPV6_ADDRZ_PAT + "$")
BRACELESS_IPV6_ADDRZ_RE = re.compile("^" + IPV6_ADDRZ_PAT[2:-2] + "$")
ZONE_ID_RE = re.compile("(" + ZONE_ID_PAT + r")\]$")
-_HOST_PORT_PAT = ("^(%s|%s|%s)(?::0*([0-9]{0,5}))?$") % (
+_HOST_PORT_PAT = ("^(%s|%s|%s)(?::0*?(|0|[1-9][0-9]{0,5}))?$") % (
REG_NAME_PAT,
IPV4_PAT,
IPV6_ADDRZ_PAT,
diff --git a/test/test_util.py b/test/test_util.py
index 165a331..c8729e8 100644
--- a/test/test_util.py
+++ b/test/test_util.py
@@ -343,6 +343,13 @@ class TestUtil(object):
url = parse_url("https://example.com:0000000000080")
assert url.port == 80
+ def test_parse_url_only_zeros(self) -> None:
+ url = parse_url("https://example.com:0")
+ assert url.port == 0
+
+ url = parse_url("https://example.com:000000000000")
+ assert url.port == 0
+
def test_Url_str(self):
U = Url("http", host="google.com")
assert str(U) == U.url
--
2.27.0

View File

@ -0,0 +1,46 @@
From 955da4d03eaa6785aef40a34f440a67d736a4793 Mon Sep 17 00:00:00 2001
From: Seth Michael Larson <sethmichaellarson@gmail.com>
Date: Tue, 22 Nov 2022 17:59:57 +0000
Subject: [PATCH] [1.26] Strip leading zeros from ports
Co-authored-by: Bastian Venthur <bastian.venthur@flixbus.com>
Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>
Conflict:adapt:The line number of test_parse_url_remove_leading_zeros is adapted.
Reference:https://github.com/urllib3/urllib3/commit/955da4d03eaa6785aef40a34f440a67d736a4793
---
src/urllib3/util/url.py | 2 +-
test/test_util.py | 4 ++++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/urllib3/util/url.py b/src/urllib3/util/url.py
index 318a6d6..6793de3 100644
--- a/src/urllib3/util/url.py
+++ b/src/urllib3/util/url.py
@@ -63,7 +63,7 @@ IPV6_ADDRZ_RE = re.compile("^" + IPV6_ADDRZ_PAT + "$")
BRACELESS_IPV6_ADDRZ_RE = re.compile("^" + IPV6_ADDRZ_PAT[2:-2] + "$")
ZONE_ID_RE = re.compile("(" + ZONE_ID_PAT + r")\]$")
-_HOST_PORT_PAT = ("^(%s|%s|%s)(?::([0-9]{0,5}))?$") % (
+_HOST_PORT_PAT = ("^(%s|%s|%s)(?::0*([0-9]{0,5}))?$") % (
REG_NAME_PAT,
IPV4_PAT,
IPV6_ADDRZ_PAT,
diff --git a/test/test_util.py b/test/test_util.py
index ef6aa11..165a331 100644
--- a/test/test_util.py
+++ b/test/test_util.py
@@ -339,6 +339,10 @@ class TestUtil(object):
with pytest.raises(LocationParseError):
parse_url("https://www.google.com:-80/")
+ def test_parse_url_remove_leading_zeros(self):
+ url = parse_url("https://example.com:0000000000080")
+ assert url.port == 80
+
def test_Url_str(self):
U = Url("http", host="google.com")
assert str(U) == U.url
--
2.27.0

View File

@ -3,7 +3,7 @@
Name: python-%{srcname}
Version: 1.25.9
Release: 5
Release: 6
Summary: Sanity-friendly HTTP client for Python
License: MIT
URL: https://urllib3.readthedocs.io
@ -15,6 +15,9 @@ Patch0000: set-RECENT_DATE-not-be-older-than-2-years.patch
Patch6000: backport-CVE-2021-33503.patch
Patch6001: backport-Change-TARPIT_HOST-to-detect-isolated-network.patch
Patch6002: backport-Do-not-insert-None-into-ConnectionPool-if-it-was-empty.patch
Patch6003: backport-add-server_hostname-to-SSL_KEYWORDS.patch
Patch6004: backport-strip-leading-zeros-form-ports.patch
Patch6005: backport-fixed-issue-with-port-0-returning-None.patch
%global _description \
HTTP library with thread-safe connection pooling, file post support,\
@ -116,6 +119,12 @@ PYTHONPATH=%{buildroot}%{python3_sitelib}:%{python3_sitelib} %{__python3} -m pyt
%{python3_sitelib}/urllib3-*.egg-info
%changelog
* Mon Jan 16 2023 chenhaixing <chenhaixing@huawei.com> - 1.25.9-6
- Type:bugfix
- CVE:NA
- SUG:NA
- DESC:backport some patches
* Thu Jan 5 2023 chenhaixing <chenhaixing@huawei.com> - 1.25.9-5
- Type:bugfix
- CVE:NA