From fcb8ae9b86b5f1ecc998b032b42be6f153b28eea Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Wed, 15 Jan 2020 19:20:53 -0700 Subject: [PATCH] Only check the first 4 characters. --- Lib/encodings/idna.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/encodings/idna.py b/Lib/encodings/idna.py index f6c32a2234f..21f9cf52658 100644 --- a/Lib/encodings/idna.py +++ b/Lib/encodings/idna.py @@ -88,7 +88,7 @@ def ToASCII(label): raise UnicodeError("label empty or too long") # Step 5: Check ACE prefix - if label.lower().startswith(sace_prefix): + if label[:4].lower() == sace_prefix: raise UnicodeError("Label starts with ACE prefix") # Step 6: Encode with PUNYCODE @@ -121,7 +121,7 @@ def ToUnicode(label): except UnicodeError: raise UnicodeError("Invalid character in IDN label") # Step 3: Check for ACE prefix - if not label.lower().startswith(ace_prefix): + if not label[:4].lower() == ace_prefix: return str(label, "ascii") # Step 4: Remove ACE prefix