faster html escaping code from rails master