You've already forked certbot-ubuntu
extended input validation
This commit is contained in:
@@ -33,6 +33,7 @@ printf -- "sudo ./certbotinstall -p 1234AkkbdceewEFJK\n\n"
|
|||||||
#
|
#
|
||||||
clear
|
clear
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Check if no arguments were given
|
# Check if no arguments were given
|
||||||
#
|
#
|
||||||
@@ -52,10 +53,17 @@ while [[ $# -gt 0 ]]; do
|
|||||||
fi
|
fi
|
||||||
apitoken="$1"
|
apitoken="$1"
|
||||||
|
|
||||||
# Validate token at least 20 chars alphanum + - _
|
#
|
||||||
if [[ ! "$apitoken" =~ ^[A-Za-z0-9_-]{20,}$ ]]; then
|
# Validate Cloudflare API token format
|
||||||
echo "ERROR: API token format seems invalid."
|
#
|
||||||
echo "Cloudflare API tokens are usually long strings with letters, numbers, - and _."
|
if [[ "$apitoken" =~ [[:space:]] ]]; then
|
||||||
|
printf "\nERROR: API token cannot contain spaces or line breaks.\n\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! "$apitoken" =~ ^[A-Za-z0-9_-]{20,120}$ ]]; then
|
||||||
|
printf "\nERROR: Invalid API token format.\n"
|
||||||
|
printf "Expected 20–120 characters (A–Z, a–z, 0–9, - or _).\n\n"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user