mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-12-25 14:20:18 +00:00
Fix Faulty Regex pattern in custom DNS domain validation (#5291)
This commit is contained in:
commit
fc67de8c19
2 changed files with 28 additions and 1 deletions
|
@ -664,7 +664,7 @@ checkDomain()
|
|||
local domain validDomain
|
||||
# Convert to lowercase
|
||||
domain="${1,,}"
|
||||
validDomain=$(grep -P "^((-|_)*[a-z0-9]((-|_)*[a-z0-9)*(-|_)*)(\\.(-|_)*([a-z0-9]((-|_)*[a-z0-9])*))*$" <<< "${domain}") # Valid chars check
|
||||
validDomain=$(grep -P "^((-|_)*[a-z0-9]((-|_)*[a-z0-9])*(-|_)*)(\\.(-|_)*([a-z0-9]((-|_)*[a-z0-9])*))*$" <<< "${domain}") # Valid chars check
|
||||
validDomain=$(grep -P "^[^\\.]{1,63}(\\.[^\\.]{1,63})*$" <<< "${validDomain}") # Length of each label
|
||||
echo "${validDomain}"
|
||||
}
|
||||
|
|
|
@ -1151,3 +1151,30 @@ def test_package_manager_has_web_deps(host):
|
|||
|
||||
assert "No package" not in output.stdout
|
||||
assert output.rc == 0
|
||||
|
||||
|
||||
def test_webpage_sh_valid_domain(host):
|
||||
"""Confirms checkDomain function in webpage.sh works as expected"""
|
||||
check1 = host.run(
|
||||
"""
|
||||
source /opt/pihole/webpage.sh
|
||||
checkDomain "pi-hole.net"
|
||||
"""
|
||||
)
|
||||
check2 = host.run(
|
||||
"""
|
||||
source /opt/pihole/webpage.sh
|
||||
checkDomain "ab.pi-hole.net"
|
||||
"""
|
||||
)
|
||||
|
||||
check3 = host.run(
|
||||
"""
|
||||
source /opt/pihole/webpage.sh
|
||||
checkDomain "abc.pi-hole.net"
|
||||
"""
|
||||
)
|
||||
|
||||
assert "pi-hole.net" in check1.stdout
|
||||
assert "ab.pi-hole.net" in check2.stdout
|
||||
assert "abc.pi-hole.net" in check3.stdout
|
||||
|
|
Loading…
Reference in a new issue