mirror of
https://github.com/caronc/apprise.git
synced 2025-01-29 09:18:47 +01:00
Single alpha characters for subdomains still identify as a valid hostname (#475)
This commit is contained in:
parent
9b5815ef6e
commit
d248012d8b
@ -246,9 +246,10 @@ def is_hostname(hostname, ipv4=True, ipv6=True, underscore=True):
|
|||||||
# being able to address services in other stacks, we also allow
|
# being able to address services in other stacks, we also allow
|
||||||
# underscores in hostnames (if flag is set accordingly)
|
# underscores in hostnames (if flag is set accordingly)
|
||||||
# - labels can not exceed 63 characters
|
# - labels can not exceed 63 characters
|
||||||
|
# - allow single character alpha characters
|
||||||
allowed = re.compile(
|
allowed = re.compile(
|
||||||
r'^[a-z0-9][a-z0-9_-]{1,62}(?<![_-])$' if underscore else
|
r'^([a-z0-9][a-z0-9_-]{1,62}|[a-z_-])(?<![_-])$' if underscore else
|
||||||
r'^[a-z0-9][a-z0-9-]{1,62}(?<!-)$',
|
r'^([a-z0-9][a-z0-9-]{1,62}|[a-z-])(?<!-)$',
|
||||||
re.IGNORECASE,
|
re.IGNORECASE,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -605,6 +605,10 @@ def test_is_hostname():
|
|||||||
assert utils.is_hostname(
|
assert utils.is_hostname(
|
||||||
'2001:0db8:85a3:0000:0000:8a2e:0370:7334', ipv6=False) is False
|
'2001:0db8:85a3:0000:0000:8a2e:0370:7334', ipv6=False) is False
|
||||||
|
|
||||||
|
# Test hostnames with a single character hostname
|
||||||
|
assert utils.is_hostname(
|
||||||
|
'cloud.a.example.com', ipv4=False, ipv6=False) == 'cloud.a.example.com'
|
||||||
|
|
||||||
|
|
||||||
def test_is_ipaddr():
|
def test_is_ipaddr():
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user