mirror of
https://github.com/pi-hole/pi-hole
synced 2024-11-18 06:08:21 +00:00
Accept underscores when validating domain names (#1571)
This commit is contained in:
parent
ab1a6d8829
commit
ec4e9780ed
@ -62,11 +62,14 @@ EscapeRegexp() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
HandleOther() {
|
HandleOther() {
|
||||||
# First, convert everything to lowercase
|
# Convert to lowercase
|
||||||
domain=$(sed -e "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/" <<< "$1")
|
domain="${1,,}"
|
||||||
|
|
||||||
# Check validity of domain
|
# Check validity of domain
|
||||||
validDomain=$(echo "${domain}" | perl -lne 'print if /(?!.*[^a-z0-9-\.].*)^((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9-]+\.)*[a-z]{2,63}/')
|
validDomain=$(perl -lne 'print if /^((-|_)*[a-z\d]((-|_)*[a-z\d])*(-|_)*)(\.(-|_)*([a-z\d]((-|_)*[a-z\d])*))*$/' <<< "${domain}") # Valid chars check
|
||||||
|
validDomain=$(perl -lne 'print if /^.{1,253}$/' <<< "${validDomain}") # Overall length check
|
||||||
|
validDomain=$(perl -lne 'print if /^[^\.]{1,63}(\.[^\.]{1,63})*$/' <<< "${validDomain}") # Length of each label
|
||||||
|
|
||||||
if [[ -z "${validDomain}" ]]; then
|
if [[ -z "${validDomain}" ]]; then
|
||||||
echo -e " ${CROSS} $1 is not a valid argument or domain name!"
|
echo -e " ${CROSS} $1 is not a valid argument or domain name!"
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user