diff --git a/advanced/Scripts/list.sh b/advanced/Scripts/list.sh index e7151cf6..86589083 100755 --- a/advanced/Scripts/list.sh +++ b/advanced/Scripts/list.sh @@ -62,11 +62,14 @@ EscapeRegexp() { } HandleOther() { - # First, convert everything to lowercase - domain=$(sed -e "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/" <<< "$1") + # Convert to lowercase + domain="${1,,}" # 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 echo -e " ${CROSS} $1 is not a valid argument or domain name!" else @@ -98,7 +101,7 @@ PoplistFile() { AddDomain() { list="$2" domain=$(EscapeRegexp "$1") - + [[ "${list}" == "${whitelist}" ]] && listname="whitelist" [[ "${list}" == "${blacklist}" ]] && listname="blacklist" [[ "${list}" == "${wildcardlist}" ]] && listname="wildcard blacklist" @@ -151,7 +154,7 @@ AddDomain() { RemoveDomain() { list="$2" domain=$(EscapeRegexp "$1") - + [[ "${list}" == "${whitelist}" ]] && listname="whitelist" [[ "${list}" == "${blacklist}" ]] && listname="blacklist" [[ "${list}" == "${wildcardlist}" ]] && listname="wildcard blacklist"