diff --git a/certbotinstall b/certbotinstall index a5bc93f..0b8f2e1 100755 --- a/certbotinstall +++ b/certbotinstall @@ -33,6 +33,7 @@ printf -- "sudo ./certbotinstall -p 1234AkkbdceewEFJK\n\n" # clear + # # Check if no arguments were given # @@ -52,10 +53,17 @@ while [[ $# -gt 0 ]]; do fi apitoken="$1" - # Validate token at least 20 chars alphanum + - _ - if [[ ! "$apitoken" =~ ^[A-Za-z0-9_-]{20,}$ ]]; then - echo "ERROR: API token format seems invalid." - echo "Cloudflare API tokens are usually long strings with letters, numbers, - and _." + # + # Validate Cloudflare API token format + # + 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 fi