Merged Eric Kow's HTML escaping patch