mirror of
https://github.com/StevenBlack/hosts.git
synced 2026-07-01 02:36:52 +00:00
Add support for exotic TLDs.
Indeed, before this patch, we were not supporting TLD which contains digits and dashes (-) when "puny-encoded".
This commit is contained in:
@@ -1061,7 +1061,10 @@ def normalize_rule(rule, target_ip, keep_domain_comments):
|
||||
"""
|
||||
first try: IP followed by domain
|
||||
"""
|
||||
regex = r"^\s*(\d{1,3}\.){3}\d{1,3}\s+((?:\w+\.)+[a-zA-Z\.-]+)(.*)"
|
||||
|
||||
# WARNING:
|
||||
# [a-zA-Z0-9\-]+ is NOT an issue. (e.g., xn--p1ai TLD - and others).
|
||||
regex = r"^\s*(\d{1,3}\.){3}\d{1,3}\s+((?:[\w\-\.]+\.)+[a-zA-Z0-9\-]+)(.*)"
|
||||
result = re.search(regex, rule)
|
||||
|
||||
if result:
|
||||
@@ -1090,7 +1093,9 @@ def normalize_rule(rule, target_ip, keep_domain_comments):
|
||||
"""
|
||||
# deny any potential IPv6 address here.
|
||||
if ":" not in rule:
|
||||
regex = r"^\s*((?:\w+\.)+[a-zA-Z\.-]+)(.*)"
|
||||
# WARNING:
|
||||
# [a-zA-Z0-9\-]+ is NOT an issue. (e.g., xn--p1ai TLD - and others).
|
||||
regex = r"^\s*((?:[\w\-\.]+\.)+[a-zA-Z0-9\-]+)(.*)"
|
||||
result = re.search(regex, rule)
|
||||
|
||||
if result:
|
||||
|
||||
Reference in New Issue
Block a user