diff --git a/vpnsetup.sh b/vpnsetup.sh index 3caf615..e5d60cb 100755 --- a/vpnsetup.sh +++ b/vpnsetup.sh @@ -101,9 +101,13 @@ if [ -z "$VPN_IPSEC_PSK" ] || [ -z "$VPN_USER" ] || [ -z "$VPN_PASSWORD" ]; then exiterr "All VPN credentials must be specified. Edit the script and re-enter them." fi +if printf %s "$VPN_IPSEC_PSK $VPN_USER $VPN_PASSWORD" | LC_ALL=C grep -qs '[^ -~]\+'; then + exiterr "VPN credentials must not contain non-ASCII characters." +fi + case "$VPN_IPSEC_PSK $VPN_USER $VPN_PASSWORD" in *[\\\"\']*) - exiterr "VPN credentials must not contain any of these characters: \\ \" '" + exiterr "VPN credentials must not contain the following characters: \\ \" '" ;; esac diff --git a/vpnsetup_centos.sh b/vpnsetup_centos.sh index fb29eee..2e6ee3c 100755 --- a/vpnsetup_centos.sh +++ b/vpnsetup_centos.sh @@ -94,9 +94,13 @@ if [ -z "$VPN_IPSEC_PSK" ] || [ -z "$VPN_USER" ] || [ -z "$VPN_PASSWORD" ]; then exiterr "All VPN credentials must be specified. Edit the script and re-enter them." fi +if printf %s "$VPN_IPSEC_PSK $VPN_USER $VPN_PASSWORD" | LC_ALL=C grep -qs '[^ -~]\+'; then + exiterr "VPN credentials must not contain non-ASCII characters." +fi + case "$VPN_IPSEC_PSK $VPN_USER $VPN_PASSWORD" in *[\\\"\']*) - exiterr "VPN credentials must not contain any of these characters: \\ \" '" + exiterr "VPN credentials must not contain the following characters: \\ \" '" ;; esac