-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix broken HTML entities in html output #2304
Conversation
* Output is missing the & in the html entities leading to incorrect display.
Hi @Sp1l, Thanks for the PR. I tried it out on two systems: Ubuntu 20.04 and MacOS Monterey. While the PR works okay on Ubuntu, it produces incorrect results on MacOS. On MacOS, I get "\>" in the HTML rather than ">". On the other hand, the current code works for me on both systems. So, it seems that the PR needs to be modified so that it fixes the HTML on the system you are using, but doesn't break things on other systems (e.g., MacOS). Could you provide some information about the system you are using on which the broken HTML is being created (e.g., Thanks, David |
Wasn't there a CI check for MacOS too? |
I can't find any that the CI checks are performed on MacOS. Looking at .github/workflows/test.yml I only see Ubuntu 20.04 listed. Should I be looking somewhere else? In doing a search for "MacOS" I came across PR #1481 (and #1528 for the 3.0 branch). I seems that |
Hi David,
This is where I admit not having read the contributing doc... Basically stock Ubuntu 22.10 on WSL2, tend to use the PeterMosmans' SSL (I maintain the port for this on FreeBSD security/openssl-unsafe)
Is there any relation to
Cheers, Bernard. |
We've already encountered at least one problem (#1758) related to the use of bash 5.1. Perhaps this is another case of code that works with bash 5.0 and earlier, but not with bash 5.1 and later. At the moment, I don't have a system that uses bash 5.1 or later. I'll see if I can get one set up at some point so that I can do some testing on this. |
I tried out a live image of Kubuntu 22.10 and was able to reproduce the problem, but don't have a solution yet. This may help though: https://unix.stackexchange.com/questions/733148/why-doesnt-ampersand-work-in-string-replacement-without-being-escaped. It seems that issue is related to a change made in Bash 5.2. I tried the idea of putting the ampersand in quotes, and it worked in Ubuntu 20.04 and Ubuntu 22.10, but not in MacOS Monterey. On MacOS, the quotes were just included in the string, just as the stack exchange article said would happen with older versions of Bash. I guess if we can't come up with any better solution, we can have an |
As you suggested : either parse the bash version. Alternatively that could be done providing a test, parse the result and then chose the proper replacement. I am afraid that the latter could be not easy to implement in a error-free fashion looking forward. |
As noted in testssl#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 testssl#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).
As noted in testssl#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 testssl#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).
After looking through the Bash man page some more, I found something that seems to work; replacing
I tried this on Ubuntu 20.04, Ubuntu 23.10, and MacOS Monterey, and it produces the correct results on all three. I don't understand exactly under what circumstances Bash treats I submitted PRs #2317 and #2318 for the 3.1dev and 3.0 branches, respectively, that implement this solution. Assuming the CI checks pass for #2317 (as I expect), please let me know if you prefer this solution to having two different versions of |
Thanks a lot David for your PRs! No, not at all. This is way better! Thanks also @Sp1l for catching this and your suggested fix. PS: CI checks on 3.0 are still kind of broken, see #2270 . So one has to look where exactly it fails |
The
--html
flag currently produces html output with broken HTML entitiesThe patch fixes this for me