Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/pi-hole/pi-hole.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian König <ckoenig@posteo.de>2022-07-06 20:27:16 +0300
committerChristian König <ckoenig@posteo.de>2022-07-06 20:27:33 +0300
commit469776afd6abd9055a2deddd159114baf9774607 (patch)
tree0d5f97788bf2b99da3f2266403e05a7ee7b217a7
parent853cd9670a43470bf064bf6410b8b9246ea6e5d0 (diff)
Do not restrict RegEx added from CLI by length
Signed-off-by: Christian König <ckoenig@posteo.de>
-rwxr-xr-xadvanced/Scripts/list.sh18
1 files changed, 13 insertions, 5 deletions
diff --git a/advanced/Scripts/list.sh b/advanced/Scripts/list.sh
index f3f97da2..b76a7ef7 100755
--- a/advanced/Scripts/list.sh
+++ b/advanced/Scripts/list.sh
@@ -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))