From e64049af0edea713e4f0ae91d1ffd02828bcaeeb Mon Sep 17 00:00:00 2001 From: Maksim Usmanov | Maks Date: Tue, 21 Feb 2017 21:23:53 +0100 Subject: [PATCH] Fix DNS issue whit some characters This will fix issues commented here: https://github.com/serghey-rodin/vesta/issues/1087 Changes: 1- Prevent user to add record as: record* or ** of *record only can add record if has * or *. so only valid wildcards 2- Prevent add records as record has record. record.. record-- record- 3- Prevent add records as -record .record and leave user add _record needed for dmarc, dkim and orther 4- prevent add dual special characters record..record or record--recoerd or record__record or record........record --- func/main.sh | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/func/main.sh b/func/main.sh index b1761fd8..b892a61b 100644 --- a/func/main.sh +++ b/func/main.sh @@ -594,10 +594,25 @@ is_common_format_valid() { check_result $E_INVALID "invalid $2 format :: $1" fi if [[ $1 =~ \* ]]; then - if [ "$(echo $1 | grep -o '*'|wc -l)" -gt 1 ]; then - check_result $E_INVALID "invalid $2 format :: $1" + if [[ "$(echo $1 | grep -o \*\. |wc -l)" -eq 0 ]] && [[ $1 != '*' ]] ; then + check_result $E_INVALID "invalid $2 format :: $1" fi fi + if [[ $(echo -n "$1" | tail -c 1) =~ [^a-zA-Z0-9_*@] ]]; then + check_result $E_INVALID "invalid $2 format :: $1" + fi + if [[ $(echo -n "$1" | grep -c '\.\.') -gt 0 ]];then + check_result $E_INVALID "invalid $2 format :: $1" + fi + if [[ $(echo -n "$1" | head -c 1) =~ [^a-zA-Z0-9_*@] ]]; then + check_result $E_INVALID "invalid $2 format :: $1" + fi + if [[ $(echo -n "$1" | grep -c '\-\-') -gt 0 ]]; then + check_result $E_INVALID "invalid $2 format :: $1" + fi + if [[ $(echo -n "$1" | grep -c '\_\_') -gt 0 ]]; then + check_result $E_INVALID "invalid $2 format :: $1" + fi } # Database format validator