diff options
Diffstat (limited to 'meta-python/recipes-devtools/python/python3-yarl')
| -rw-r--r-- | meta-python/recipes-devtools/python/python3-yarl/0001-Correct-square-bracket-handling-in-URL-netloc-882.patch | 138 |
1 files changed, 138 insertions, 0 deletions
diff --git a/meta-python/recipes-devtools/python/python3-yarl/0001-Correct-square-bracket-handling-in-URL-netloc-882.patch b/meta-python/recipes-devtools/python/python3-yarl/0001-Correct-square-bracket-handling-in-URL-netloc-882.patch new file mode 100644 index 0000000000..293ce88a13 --- /dev/null +++ b/meta-python/recipes-devtools/python/python3-yarl/0001-Correct-square-bracket-handling-in-URL-netloc-882.patch | |||
| @@ -0,0 +1,138 @@ | |||
| 1 | From 0a94c6e4948e00fff072c0cf367afbf4ac36f906 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Martijn Pieters <github.com@zopatista.com> | ||
| 3 | Date: Wed, 14 Jun 2023 11:17:16 +0100 | ||
| 4 | Subject: [PATCH] Correct square bracket handling in URL netloc (#882) | ||
| 5 | |||
| 6 | - The human representation of usernames and passwords should percent- | ||
| 7 | encode square brackets. | ||
| 8 | - Clean up the test suite to remove tests that use invalid hostnames | ||
| 9 | (square brackets in a host name must only be used for IPv6 addresses). | ||
| 10 | - Rename the remaining test using IPvFuture address syntax to make this | ||
| 11 | explicit. | ||
| 12 | - Drop a test for IPv6 addresses with a zone id; zone id support is | ||
| 13 | controversial and expilictly excluded from the WHATWG URL standard. | ||
| 14 | Zone ids *without percent characters in their name* continue to work | ||
| 15 | as long as urllib.parse.urlsplit() accepts them but this is not | ||
| 16 | something that yarl.URL() needs to support explicitly. | ||
| 17 | |||
| 18 | Upstream-Status: Backport [https://github.com/aio-libs/yarl/commit/0a94c6e4948e00fff072c0cf367afbf4ac36f906] | ||
| 19 | Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com> | ||
| 20 | |||
| 21 | --- | ||
| 22 | CHANGES/876.bugfix.rst | 1 + | ||
| 23 | tests/test_url.py | 10 ++-------- | ||
| 24 | tests/test_url_parsing.py | 28 ++-------------------------- | ||
| 25 | yarl/_url.py | 4 ++-- | ||
| 26 | 4 files changed, 7 insertions(+), 36 deletions(-) | ||
| 27 | create mode 100644 CHANGES/876.bugfix.rst | ||
| 28 | |||
| 29 | diff --git a/CHANGES/876.bugfix.rst b/CHANGES/876.bugfix.rst | ||
| 30 | new file mode 100644 | ||
| 31 | index 0000000..ef62c7e | ||
| 32 | --- /dev/null | ||
| 33 | +++ b/CHANGES/876.bugfix.rst | ||
| 34 | @@ -0,0 +1 @@ | ||
| 35 | +Fixed the human representation of URLs with square brackets in usernames and passwords. | ||
| 36 | diff --git a/tests/test_url.py b/tests/test_url.py | ||
| 37 | index 1981b20..295c063 100644 | ||
| 38 | --- a/tests/test_url.py | ||
| 39 | +++ b/tests/test_url.py | ||
| 40 | @@ -236,12 +236,6 @@ def test_compressed_ipv6(): | ||
| 41 | assert url.host == url.raw_host | ||
| 42 | |||
| 43 | |||
| 44 | -def test_ipv6_zone(): | ||
| 45 | - url = URL("http://[fe80::822a:a8ff:fe49:470c%тест%42]:123") | ||
| 46 | - assert url.raw_host == "fe80::822a:a8ff:fe49:470c%тест%42" | ||
| 47 | - assert url.host == url.raw_host | ||
| 48 | - | ||
| 49 | - | ||
| 50 | def test_ipv4_zone(): | ||
| 51 | # I'm unsure if it is correct. | ||
| 52 | url = URL("http://1.2.3.4%тест%42:123") | ||
| 53 | @@ -1660,8 +1654,8 @@ def test_human_repr_delimiters(): | ||
| 54 | s = url.human_repr() | ||
| 55 | assert URL(s) == url | ||
| 56 | assert ( | ||
| 57 | - s == "http:// !\"%23$%25&'()*+,-.%2F%3A;<=>%3F%40[\\]^_`{|}~" | ||
| 58 | - ": !\"%23$%25&'()*+,-.%2F%3A;<=>%3F%40[\\]^_`{|}~" | ||
| 59 | + s == "http:// !\"%23$%25&'()*+,-.%2F%3A;<=>%3F%40%5B\\%5D^_`{|}~" | ||
| 60 | + ": !\"%23$%25&'()*+,-.%2F%3A;<=>%3F%40%5B\\%5D^_`{|}~" | ||
| 61 | "@хост.домен:8080" | ||
| 62 | "/ !\"%23$%25&'()*+,-./:;<=>%3F@[\\]^_`{|}~" | ||
| 63 | "? !\"%23$%25%26'()*%2B,-./:%3B<%3D>?@[\\]^_`{|}~" | ||
| 64 | diff --git a/tests/test_url_parsing.py b/tests/test_url_parsing.py | ||
| 65 | index 0f0dd7e..60f128c 100644 | ||
| 66 | --- a/tests/test_url_parsing.py | ||
| 67 | +++ b/tests/test_url_parsing.py | ||
| 68 | @@ -178,14 +178,6 @@ class TestHost: | ||
| 69 | assert u.query_string == "" | ||
| 70 | assert u.fragment == "" | ||
| 71 | |||
| 72 | - def test_masked_ipv4(self): | ||
| 73 | - u = URL("//[127.0.0.1]/") | ||
| 74 | - assert u.scheme == "" | ||
| 75 | - assert u.host == "127.0.0.1" | ||
| 76 | - assert u.path == "/" | ||
| 77 | - assert u.query_string == "" | ||
| 78 | - assert u.fragment == "" | ||
| 79 | - | ||
| 80 | def test_ipv6(self): | ||
| 81 | u = URL("//[::1]/") | ||
| 82 | assert u.scheme == "" | ||
| 83 | @@ -194,15 +186,7 @@ class TestHost: | ||
| 84 | assert u.query_string == "" | ||
| 85 | assert u.fragment == "" | ||
| 86 | |||
| 87 | - def test_strange_ip(self): | ||
| 88 | - u = URL("//[-1]/") | ||
| 89 | - assert u.scheme == "" | ||
| 90 | - assert u.host == "-1" | ||
| 91 | - assert u.path == "/" | ||
| 92 | - assert u.query_string == "" | ||
| 93 | - assert u.fragment == "" | ||
| 94 | - | ||
| 95 | - def test_strange_ip_2(self): | ||
| 96 | + def test_ipvfuture_address(self): | ||
| 97 | u = URL("//[v1.-1]/") | ||
| 98 | assert u.scheme == "" | ||
| 99 | assert u.host == "v1.-1" | ||
| 100 | @@ -210,14 +194,6 @@ class TestHost: | ||
| 101 | assert u.query_string == "" | ||
| 102 | assert u.fragment == "" | ||
| 103 | |||
| 104 | - def test_strange_ip_3(self): | ||
| 105 | - u = URL("//v1.[::1]/") | ||
| 106 | - assert u.scheme == "" | ||
| 107 | - assert u.host == "::1" | ||
| 108 | - assert u.path == "/" | ||
| 109 | - assert u.query_string == "" | ||
| 110 | - assert u.fragment == "" | ||
| 111 | - | ||
| 112 | |||
| 113 | class TestPort: | ||
| 114 | def test_canonical(self): | ||
| 115 | @@ -320,7 +296,7 @@ class TestUserInfo: | ||
| 116 | assert u.fragment == "" | ||
| 117 | |||
| 118 | def test_weird_user3(self): | ||
| 119 | - u = URL("//[some]@host") | ||
| 120 | + u = URL("//%5Bsome%5D@host") | ||
| 121 | assert u.scheme == "" | ||
| 122 | assert u.user == "[some]" | ||
| 123 | assert u.password is None | ||
| 124 | diff --git a/yarl/_url.py b/yarl/_url.py | ||
| 125 | index 74190d9..c8f2acb 100644 | ||
| 126 | --- a/yarl/_url.py | ||
| 127 | +++ b/yarl/_url.py | ||
| 128 | @@ -1118,8 +1118,8 @@ class URL: | ||
| 129 | |||
| 130 | def human_repr(self): | ||
| 131 | """Return decoded human readable string for URL representation.""" | ||
| 132 | - user = _human_quote(self.user, "#/:?@") | ||
| 133 | - password = _human_quote(self.password, "#/:?@") | ||
| 134 | + user = _human_quote(self.user, "#/:?@[]") | ||
| 135 | + password = _human_quote(self.password, "#/:?@[]") | ||
| 136 | host = self.host | ||
| 137 | if host: | ||
| 138 | host = self._encode_host(self.host, human=True) | ||
