Skip to content

Commit 3d82f7c

Browse files
author
David Cooper
committed
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).
1 parent 70237b2 commit 3d82f7c

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

testssl.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -535,11 +535,11 @@ html_reserved(){
535535
local output
536536
"$do_html" || return 0
537537
#sed -e 's/\&/\&amp;/g' -e 's/</\&lt;/g' -e 's/>/\&gt;/g' -e 's/"/\&quot;/g' -e "s/'/\&apos;/g" <<< "$1"
538-
output="${1//&/&amp;}"
539-
output="${output//</&lt;}"
540-
output="${output//>/&gt;}"
541-
output="${output//\"/&quot;}"
542-
output="${output//\'/&apos;}"
538+
output="${1//&/$'&'amp;}"
539+
output="${output//</$'&'lt;}"
540+
output="${output//>/$'&'gt;}"
541+
output="${output//\"/$'&'quot;}"
542+
output="${output//\'/$'&'apos;}"
543543
printf -- "%s" "$output"
544544
return 0
545545
}

0 commit comments

Comments
 (0)