国内外主机
测评及优惠码

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

最近在使用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 {
                '<':'<',
                '&':'&',
                '"':'"',
                '>':'>',
                "'":'&#39;'
            }[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

赞(0)
版权声明:本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权
文章名称:《ueditor编辑器双引号 &ldquo;&rdquo;转义BUG的修复》
文章链接:https://www.ibytx.com/720.html
本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。

登录

找回密码

注册