mirror of
https://github.com/StevenBlack/hosts.git
synced 2026-07-01 02:36:52 +00:00
Tighten regex rule to discard IP address as hostname
This commit is contained in:
@@ -501,7 +501,8 @@ def normalize_rule(rule):
|
||||
The rule string with spelling and spacing reformatted.
|
||||
"""
|
||||
|
||||
result = re.search(r'^[ \t]*(\d+\.\d+\.\d+\.\d+)\s+([\w\.-]+)(.*)', rule)
|
||||
result = re.search(r'^\s*(\d{1,3}\.){3}\d{1,3}\s+([\w\.-]+[a-zA-Z])(.*)',
|
||||
rule)
|
||||
if result:
|
||||
hostname, suffix = result.group(2, 3)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user