I would also say if you have stupid HTML guys (and don't we all) consider using a templating system that limits the amount of damage they can do, e.g.
HTML::Template.
I guess you also might ask why are null (or even blank) titles allowed for a document. To me, this is an example of why properly designed databases, including constraints, etc, are so important. It can mean a lot of these sort of problems simply disappearing. And yet many developers (including myself) often skip over things like constraints, or make them wide open just because it's "easier".
(Of course, either of these points may not be applicable to your particular project, but they're the sort of things I'd be thinking about if I encountered this type of bug).