From 5c0b8314d052a8a715258a893285771edecb9439 Mon Sep 17 00:00:00 2001 From: David Cooper Date: Fri, 3 Feb 2023 14:31:08 -0800 Subject: [PATCH] Fix HTML output in Bash 5.2 and newer As noted in #2304, the way that the '&' character is treated in the string part of a pattern substitution changed in Bash 5.2. As a result, the change that was made in #1481 to accommodate older versions of Bash (e.g., on MacOS) now causes testssl.sh to produce incorrect HTML output when run on Bash 5.2. This commit encodes the '&' characters in the substitution strings in a way that produces correct results on multiple versions of Bash (3.2 on MacOS, 5.2 on Ubuntu 23.10, 5.0 on Ubuntu 20.04). --- testssl.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/testssl.sh b/testssl.sh index 1a07dcf..6533e15 100755 --- a/testssl.sh +++ b/testssl.sh @@ -491,11 +491,11 @@ html_reserved(){ local output "$do_html" || return 0 #sed -e 's/\&/\&/g' -e 's//\>/g' -e 's/"/\"/g' -e "s/'/\'/g" <<< "$1" - output="${1//&/&}" - output="${output///>}" - output="${output//\"/"}" - output="${output//\'/'}" + output="${1//&/$'&'amp;}" + output="${output///$'&'gt;}" + output="${output//\"/$'&'quot;}" + output="${output//\'/$'&'apos;}" printf -- "%s" "$output" return 0 }