Change uppercase regex

Check for any uppercase characters rather than revalidating input sans uppercase
This commit is contained in:
William Wernert
2021-07-16 15:39:09 -04:00
parent b552973e00
commit 0deb77468f
2 changed files with 10 additions and 16 deletions

View File

@@ -160,14 +160,6 @@ fail() {
exit 1
}
fqdn_lowercase() {
local fqdn=$1
echo "$fqdn" | grep -qP '(?=^.{4,253}$)(^((?!-)[a-z0-9-]{0,62}[a-z0-9]\.)+[a-z]{2,63}$)' \
&& return 0 \
|| return 1
}
get_random_value() {
length=${1:-20}
head -c 5000 /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w $length | head -n 1
@@ -194,12 +186,6 @@ header() {
printf '%s\n' "" "$banner" " $*" "$banner"
}
hostname_lowercase() {
local hostname=$1
[[ $hostname =~ ^[a-z0-9\-]+$ ]] && return 0 || return 1
}
init_monitor() {
MONITORNIC=$1
@@ -386,6 +372,14 @@ set_version() {
fi
}
has_uppercase() {
local string=$1
echo "$string" | grep -qP '[A-Z]' \
&& return 0 \
|| return 1
}
valid_cidr() {
# Verify there is a backslash in the string
echo "$1" | grep -qP "^[^/]+/[^/]+$" || return 1

View File

@@ -425,7 +425,7 @@ collect_homenet_snsr() {
collect_hostname() {
collect_hostname_validate
while ! hostname_lowercase "$HOSTNAME"; do
while has_uppercase "$HOSTNAME"; do
if ! (whiptail_uppercase_warning); then
collect_hostname_validate
else
@@ -664,7 +664,7 @@ collect_proxy_details() {
collect_redirect_host() {
collect_redirect_host_validate
while ! hostname_lowercase "$REDIRECTHOST" && ! fqdn_lowercase "$REDIRECTHOST"; do
while has_uppercase "$REDIRECTHOST"; do
local text
! valid_hostname "$REDIRECTHOST" && text="domain name" || text="hostname"
if ! (whiptail_uppercase_warning "$text"); then