Skip to content

Commit

Permalink
Merge pull request pi-hole#4786 from pi-hole/regex_lenght
Browse files Browse the repository at this point in the history
Do not restrict RegEx added from CLI by length
  • Loading branch information
yubiuser authored Jul 6, 2022
2 parents e05b64b + 469776a commit 3d4476c
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions advanced/Scripts/list.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,29 @@ Options:
ValidateDomain() {
# Convert to lowercase
domain="${1,,}"
local str validDomain

# 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
validDomain="${domain}"
else
if [[ ( "${typeId}" == "${regex_blacklist}" || "${typeId}" == "${regex_whitelist}" ) && "${wildcard}" == false ]]; then
validDomain="${domain}"
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 "^[^\\.]{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

if [[ -n "${validDomain}" ]]; then
domList=("${domList[@]}" "${validDomain}")
else
echo -e " ${CROSS} ${domain} is not a valid argument or domain name!"
echo -e " ${CROSS} ${domain} ${str}"
fi

domaincount=$((domaincount+1))
Expand Down

0 comments on commit 3d4476c

Please sign in to comment.