diff options
author | Darren 'Tadgy' Austin <darren@afterdark.org.uk> | 2021-03-08 22:58:01 +0000 |
---|---|---|
committer | Darren 'Tadgy' Austin <darren@afterdark.org.uk> | 2021-03-08 22:58:01 +0000 |
commit | 39ff28c3f36673e373dac6d2a8a12f0bf0dfceff (patch) | |
tree | a36f5d22e87bb178df218dba0ab851c3a11a391c /netconfig | |
parent | 908f03bd53526adb20a56b91f2b343dc57ec6d02 (diff) | |
download | slacknetsetup-39ff28c3f36673e373dac6d2a8a12f0bf0dfceff.tar.xz |
Fix domain name validation checks. Thanks to xbeastx74 on LQ for the report.
Diffstat (limited to 'netconfig')
-rw-r--r-- | netconfig | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -492,8 +492,11 @@ EOF DOMAIN="`cat $TMP/SeTdom`" rm -f $TMP/SeTdom $TMP/tempmsg # These regexes doon't catch everything, just basic syntax mistakes. - if [ "$DOMAIN" = "" ] || [[ ! "$DOMAIN" =~ ^([[:alnum:]]+[-.]*[[:alnum:]]+)+$ ]] || \ - [[ "${DOMAIN:0:1}" =~ ^[.-]$ ]] || [[ "${DOMAIN: -1:1}" == ^[.-]$ ]]; then + DN="${DOMAIN%.*}" + TLD="${DOMAIN##*.}" + if [ -z "$DOMAIN" ] || [ -z "$TLD" ] || [ -z "$DN" ] || [[ ! "$DOMAIN" =~ ^[^.-][[:alnum:].-]+[^.-]$ ]] || \ + [[ ! "$DN" =~ ^[^.-][[:alnum:].-]+[^.-]$ ]] || [[ "$DN" =~ \.\. ]] || [[ "$DN" =~ -- ]] || \ + [[ ! "$TLD" =~ ^[^-][[:alnum:]-]+[^-]$ ]]; then dialog --title "DOMAINNAME" --ok-button "Back" --msgbox \ "That doesn't appear to be a valid domain name.\n Domain names can only contain letters and numbers, hyphens |