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
This commit is contained in:
Maksim Usmanov | Maks 2017-02-21 21:23:53 +01:00 committed by GitHub
commit e64049af0e

View file

@ -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