Fix URL when hostname with trailing dot supplied

Hostnames can contain a trailing dot (and sometimes they should).
If they are supplied to testssl.sh however they will be also interpreted
as a URL PATH when the servive is HTTP.

This commit fixes that.
This commit is contained in:
Dirk 2020-02-03 22:26:01 +01:00
parent ccafd9125b
commit c2df2f1fc0
1 changed files with 2 additions and 1 deletions

View File

@ -18802,8 +18802,9 @@ parse_hn_port() {
SNI="-servername $NODE" SNI="-servername $NODE"
URL_PATH=$(sed 's/https:\/\///' <<< "$1" | sed 's/'"${NODE}"'//' | sed 's/.*'"${PORT}"'//') # remove protocol and node part and port URL_PATH=$(sed 's/https:\/\///' <<< "$1" | sed 's/'"${NODE}"'//' | sed 's/.*'"${PORT}"'//') # remove protocol and node part and port
URL_PATH=$(sed 's/\/\//\//g' <<< "$URL_PATH") # we rather want // -> / URL_PATH=$(sed 's/\/\//\//g' <<< "$URL_PATH") # we rather want // -> /
URL_PATH=${URL_PATH%%.} # strip trailing "." so that it is not interpreted as URL
[[ -z "$URL_PATH" ]] && URL_PATH="/" [[ -z "$URL_PATH" ]] && URL_PATH="/"
debugme echo $URL_PATH debugme echo "URL_PATH: $URL_PATH"
return 0 # NODE, URL_PATH, PORT is set now return 0 # NODE, URL_PATH, PORT is set now
} }