From 9cea1cdc67a2f3439321768427abcf2214c54c1b Mon Sep 17 00:00:00 2001 From: Hubert Kario Date: Sat, 19 Sep 2015 19:43:27 +0200 Subject: [PATCH] handle hostnames that are URIs fixes #83 --- cipherscan | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cipherscan b/cipherscan index c902f35..ca0e181 100755 --- a/cipherscan +++ b/cipherscan @@ -1481,10 +1481,18 @@ unset PARAMS[-1] # Refuse to proceed if the hostname starts with a hyphen, since hostnames can't # begin with a hyphen and this likely means we accidentally parsed an option as # a hostname. -if [[ -z $TARGET || $TARGET =~ ^[-:] || $TARGET =~ :.*[^0-9] ]]; then +if [[ -z $TARGET || $TARGET =~ ^[-:] ]]; then echo "The final argument '$TARGET' is not a valid HOST[:PORT]." 1>&2 exit 1 fi +# Handle Targets that are URIs +if [[ $TARGET =~ /([^/]+)(/|$) ]]; then + TARGET="${BASH_REMATCH[1]}" +fi +if [[ $TARGET =~ :.*[^0-9] ]]; then + echo "Final argument is not a valid HOST[:PORT]" >&2 + exit 1 +fi if ! [[ $TARGET =~ : ]]; then sni_target=$TARGET TARGET="${TARGET}:443"