Some sanitisation

This is a patch that addresses some of the worst XSS vulns, it is obviously incomplete.