From 9f16a0c266ff9a8592d5d0cef6f261c3761266a3 Mon Sep 17 00:00:00 2001 From: Wu Tingfeng Date: Sat, 9 Mar 2024 06:00:36 +0800 Subject: [PATCH] Use non-capturing groups for IPv4 address detection (#323) --- tldextract/remote.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tldextract/remote.py b/tldextract/remote.py index 08b07221..8ac83111 100644 --- a/tldextract/remote.py +++ b/tldextract/remote.py @@ -7,8 +7,9 @@ from urllib.parse import scheme_chars IP_RE = re.compile( - r"^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.)" - r"{3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$" + r"^(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.)" + r"{3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$", + re.ASCII, ) scheme_chars_set = set(scheme_chars)