mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
[3.11] gh-98433: Fix quadratic time idna decoding. (GH-99092) (#99222)
There was an unnecessary quadratic loop in idna decoding. This restores
the behavior to linear.
(cherry picked from commit d315722564
)
Co-authored-by: Gregory P. Smith <greg@krypto.org>
This commit is contained in:
parent
1add2393a8
commit
a6f6c3a3d6
3 changed files with 27 additions and 17 deletions
|
@ -1553,6 +1553,12 @@ class IDNACodecTest(unittest.TestCase):
|
|||
self.assertEqual("pyth\xf6n.org".encode("idna"), b"xn--pythn-mua.org")
|
||||
self.assertEqual("pyth\xf6n.org.".encode("idna"), b"xn--pythn-mua.org.")
|
||||
|
||||
def test_builtin_decode_length_limit(self):
|
||||
with self.assertRaisesRegex(UnicodeError, "too long"):
|
||||
(b"xn--016c"+b"a"*1100).decode("idna")
|
||||
with self.assertRaisesRegex(UnicodeError, "too long"):
|
||||
(b"xn--016c"+b"a"*70).decode("idna")
|
||||
|
||||
def test_stream(self):
|
||||
r = codecs.getreader("idna")(io.BytesIO(b"abc"))
|
||||
r.read(3)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue