I spoke to Brian about this. We want to avoid using marking usernames as HtmlSafe because they actually aren't.
The proper solution is to do all the following:
- avoid automatically HTML encoding the username in macro parameters – solvable with a new GlobalHelper.renderConfluenceMacro that takes a String.format()-style string1
- avoid automatically HTML encoding the username in the user hover ID – solvable by adding a new Velocity macro to menu-macros.vm which uses a variable with an 'Html' suffix
- ensure usernames in URLs are URL-encoded, in addition to automatic HTML encoding – solvable with GeneralUtil.urlEncode().
I don't think this solution is particularly risky, but on the other hand, the bug is quite low priority. I'm certain there are many other problems in Confluence using usernames with ampersands, not just in the new functionality.
1 It's preferable to use String.format() instead of MessageFormat because macros use curly braces and escaping them for MessageFormat would be a hassle.
Ok I've fixed this for:
What I haven't fixed: