mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-23 06:33:44 +00:00
Merge pull request #4786 from pi-hole/regex_lenght
Do not restrict RegEx added from CLI by length
This commit is contained in:
commit
3d4476c9fb
1 changed files with 13 additions and 5 deletions
|
@ -100,21 +100,29 @@ Options:
|
||||||
ValidateDomain() {
|
ValidateDomain() {
|
||||||
# Convert to lowercase
|
# Convert to lowercase
|
||||||
domain="${1,,}"
|
domain="${1,,}"
|
||||||
|
local str validDomain
|
||||||
|
|
||||||
# Check validity of domain (don't check for regex entries)
|
# Check validity of domain (don't check for regex entries)
|
||||||
if [[ "${#domain}" -le 253 ]]; then
|
|
||||||
if [[ ( "${typeId}" == "${regex_blacklist}" || "${typeId}" == "${regex_whitelist}" ) && "${wildcard}" == false ]]; then
|
if [[ ( "${typeId}" == "${regex_blacklist}" || "${typeId}" == "${regex_whitelist}" ) && "${wildcard}" == false ]]; then
|
||||||
validDomain="${domain}"
|
validDomain="${domain}"
|
||||||
else
|
else
|
||||||
|
# Check max length
|
||||||
|
if [[ "${#domain}" -le 253 ]]; then
|
||||||
validDomain=$(grep -P "^((-|_)*[a-z\\d]((-|_)*[a-z\\d])*(-|_)*)(\\.(-|_)*([a-z\\d]((-|_)*[a-z\\d])*))*$" <<< "${domain}") # Valid chars check
|
validDomain=$(grep -P "^((-|_)*[a-z\\d]((-|_)*[a-z\\d])*(-|_)*)(\\.(-|_)*([a-z\\d]((-|_)*[a-z\\d])*))*$" <<< "${domain}") # Valid chars check
|
||||||
validDomain=$(grep -P "^[^\\.]{1,63}(\\.[^\\.]{1,63})*$" <<< "${validDomain}") # Length of each label
|
validDomain=$(grep -P "^[^\\.]{1,63}(\\.[^\\.]{1,63})*$" <<< "${validDomain}") # Length of each label
|
||||||
|
# set error string
|
||||||
|
str="is not a valid argument or domain name!"
|
||||||
|
else
|
||||||
|
validDomain=
|
||||||
|
str="is too long!"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "${validDomain}" ]]; then
|
if [[ -n "${validDomain}" ]]; then
|
||||||
domList=("${domList[@]}" "${validDomain}")
|
domList=("${domList[@]}" "${validDomain}")
|
||||||
else
|
else
|
||||||
echo -e " ${CROSS} ${domain} is not a valid argument or domain name!"
|
echo -e " ${CROSS} ${domain} ${str}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
domaincount=$((domaincount+1))
|
domaincount=$((domaincount+1))
|
||||||
|
|
Loading…
Reference in a new issue