Integrate SonarQube with your AI agent, scan for secrets and dependency risks, and explore and manage issues—all from the command line.
Start using SonarQube CLI
You are right that this should be a sanitizer for XSS (and XML injection). I will create a ticket for this, thanks for the report!
Just a small note: it prevents a majority of XSS but not necessarily all. It depends on the HTML context where the user input ends up in. For example, this is not great:
In my opinion, putting user input into a script tag is always a bad idea. But I have seen it often in the following form:
<script>
var foo = '{{ str }}';
</script>
Some systems provide encoders to turn every character into hex which could make this secure. A much more elegant solution is to put it in a data attribute and then use JavaScript to read it out though. This way the normal HTML encoding can be used.