• ADADADADAD

    前端如何防止xss攻击[ 网络知识 ]

    网络知识 时间:2024-12-04 12:32:21

    作者:文/会员上传

    简介:

    前端防止xss攻击的方法:过滤非法字符,例如:// 过滤XSS反射型漏洞filterInputTxt: function (html) {html = html.replace(/(.*]+>.*)/g,""); // HTML标记html = html.replace(/

    以下为本文的正文内容,内容仅供参考!本站为公益性网站,复制本文以及下载DOC文档全部免费。

    前端防止xss攻击的方法:

    过滤非法字符,例如:

    // 过滤XSS反射型漏洞

    filterInputTxt: function (html) {

    html = html.replace(/(.*<[^>]+>.*)/g,""); // HTML标记

    html = html.replace(/([\r\n])[\s]+/g, ""); // 换行、空格

    html = html.replace(//g, ""); // HTML注释

    html = html.replace(/['"‘’“”!@#$%^&*{}!¥()()×+=]/g, ""); // 非法字符

    html = html.replace("alert","");

    html = html.replace("eval","");

    html = html.replace(/(.*javascript.*)/gi,"");

    if (html === "") {

    html = "你好";

    }

    return html;

    }

    前端如何防止xss攻击.docx

    将本文的Word文档下载到电脑

    推荐度:

    下载
    热门标签: xss攻击前端