最近在使用ueditor編輯器的時候發現,它會把正常的“與 ”轉義為 “ ” 此文章為轉載,請大家有選擇的參考。
檢查轉義的方法發現對于“ ”是沒有做處理的,需要自己加上去
ueditor.all.js
unhtml: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] }) : ''; },修復方法:
第一個方法 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
以上就是ueditor編輯器雙引號 “”轉義BUG的修復的全部內容,希望對大家的學習和解決疑問有所幫助,也希望大家多多支持武林網。新聞熱點
疑難解答