In my experience, all the filtering should happen up front, you don't want your database polluted with nasty data.
That said, the scripts on this site are going on 10 years old. Seriously. So I wouldn't expect a high degree of security. You're lucky they even run at all.
The data in the levels database isn't put there directly by malicious users. It's emailed to us, where we then copy & paste the data into the database. In almost 3000 levels now, I haven't seen even one person put HTML in their descriptions or level names, much less malicious javascript.
If someone cracked into our posting system, we'd have more to worry about than someone putting javascript into a page.