织梦园模板网提供云优cms模板,pbootcms模板,Wordpress主题模板等各类企业新闻资讯网站模板下载服务。织梦园网站模板交流群
用户名:
密码:
注册
注册后享受折扣价

ueditor编辑器双引号 “”转义BUG的修复

织梦园模板 / 2020-07-31 / 收藏

***近在使用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 { '<':'&lt;', '&':'&amp;', '"':'&quot;', '>':'&gt;', "'":'&#39;' }[a] } }) : ''; },
html:function (str) { return str ? str.replace(/&((g|l|quo)t|amp|#39|nbsp);/g, function (m) { return { '&lt;':'<', '&amp;':'&', '&quot;':'"', '&gt;':'>', '&#39;':"'", '&nbsp;':' ' }[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 { '&lt;':'<', '&quot;':'"', '&gt;':'>', '&#39;':"'", '&nbsp;':' ', '&ldquo;':'"', '&rdquo;':'"', '&amp;':'&' }[m] }) : ''; },

备注

如果替换后无效,请检查你引用的是否是 ueditor.all.min.js

相关标签调用

收缩