HTMLFilter: handling not so well-formatted HTML gracefully