Skip to content

Commit 5c0b831

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 cd2eef3 commit 5c0b831

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
@@ -491,11 +491,11 @@ html_reserved(){
491491
local output
492492
"$do_html" || return 0
493493
#sed -e 's/\&/\&amp;/g' -e 's/</\&lt;/g' -e 's/>/\&gt;/g' -e 's/"/\&quot;/g' -e "s/'/\&apos;/g" <<< "$1"
494-
output="${1//&/&amp;}"
495-
output="${output//</&lt;}"
496-
output="${output//>/&gt;}"
497-
output="${output//\"/&quot;}"
498-
output="${output//\'/&apos;}"
494+
output="${1//&/$'&'amp;}"
495+
output="${output//</$'&'lt;}"
496+
output="${output//>/$'&'gt;}"
497+
output="${output//\"/$'&'quot;}"
498+
output="${output//\'/$'&'apos;}"
499499
printf -- "%s" "$output"
500500
return 0
501501
}

0 commit comments

Comments
 (0)