Surely we just need to invoke one of the Apache `StringUtils.escapeXX` methods somewhere?