转义方法不对, 应该使用HTML实体编码

function escapeHtml(string) {
var entityMap = {
“&”: “&”,
“<“: “<“, “>”: “>”,
‘”‘: ‘”‘,
“‘”: ”’,
“/”: ‘/’
};
return String(string).replace(/[&<>”‘\/]/g, function (s) {
return entityMap[s];
});
}

var string5 = ”

test2222

“;


发表评论 0

Your email address will not be published. Required fields are marked *