Fixes html entities when validation fails. Fixes #2614, #2476, #2787