diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-11-07 19:23:16 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-07 19:23:16 -0800 |
commit | 9bb8e18ca46fe66fa6802602f8a7228a24dd785f (patch) | |
tree | c7ed7974ccebac67643169a50e22887e94eb0244 /Lib/test/test_codecs.py | |
parent | e7781fd695c0ee44904f717eb0511cbf00b22090 (diff) | |
download | cpython-git-9bb8e18ca46fe66fa6802602f8a7228a24dd785f.tar.gz |
[3.11] gh-98433: Fix quadratic time idna decoding. (GH-99092) (GH-99222)
There was an unnecessary quadratic loop in idna decoding. This restores
the behavior to linear.
(cherry picked from commit d315722564927c7202dd6e111dc79eaf14240b0d)
(cherry picked from commit a6f6c3a3d6f2b580f2d87885c9b8a9350ad7bf15)
Co-authored-by: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
Diffstat (limited to 'Lib/test/test_codecs.py')
-rw-r--r-- | Lib/test/test_codecs.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py index 8edd5ac063..2407567261 100644 --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -1535,6 +1535,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) |