客户端安全-xss-2解决方案

1.需求

提供xss解决方案

2.方式

对需要显示在html中的用户代码进行编码

3.处理方案

1.用户的数据到后端前用下面的编码层代码进行编码。

 function htmlEncodeCharacter(character)
    {
        return character.replace(/&/g,'&')
                .replace(/</g,'&lt;')
                .replace(/>/g,'&gt;')
                .replace(/"/g,'&quot;')
                .replace(///g,'&#x2F;')
    }

2.后端获得数据的方式参数CI的xss_clean处理.

4.总结

采用现有的成熟框架的解决方案,但实际代码不是很了解。

原文地址:https://www.cnblogs.com/norm/p/6211773.html