On my website I have a form that takes in some textual user input. All works fine for "normal" characters. However when unicode characters are input... well, the plot thickens.
User inputs something like
やっぱ死にかけてる
This comes in to the server as text containing XML entity refs
やっぱ死にかけてる?
Now, when I want to serve this back to the client in HTML, how do I do it?
If I simply output the string as it is, there could be a chance for a script attack. If I try to encode it with scala.xml.Text
it gets converted to:
やっぱ死にかけてる?
Is there a better ready-made solution in Scala which can detect entity refs and not escape them, yet escape XML tags?