最近在使用ueditor編輯器的時候發(fā)現(xiàn),它會把正常的“ 與 ”轉(zhuǎn)義為 “ ”
檢查轉(zhuǎn)義的方法發(fā)現(xiàn)對于“ ”是沒有做處理的,需要自己加上去
ueditor.all.jsunhtml:function (str, reg) { return str ? str.replace(reg || /[&<">'](?:(amp|lt|quot|gt|#39|nbsp);)?/g, function (a, b) { if (b) { return a; } else { return { '<':'<', '&':'&', '"':'"', '>':'>', "'":''' }[a] } }) : '';},html:function (str) { return str ? str.replace(/&((g|l|quo)t|amp|#39|nbsp);/g, function (m) { return { '<':'<', '&':'&', '"':'"', '>':'>', ''':"'", ' ':' ' }[m] }) : '';},修復(fù)方法:
第一個方法 unhtml 把 amp|lt|quot|gt|#39|nbsp 替換為 amp|lt|quot|gt|#39|nbsp|ldquo|rdquo就可以了
第二個方法html
修改成
html:function (str) { return str ? str.replace(/&((g|l|quo)t|#39|nbsp|ldquo|rdquo|amp);/g, function (m) { return { '<':'<', '"':'"', '>':'>', ''':"'", ' ':' ', '“':'“', '”':'”', '&':'&' }[m] }) : '';},備注
如果替換后無效,請檢查你引用的是否是 ueditor.all.min.js
新聞熱點
疑難解答
圖片精選