检查javascript注入的方法

Ale*_*lov 1 javascript xss jquery

是否足以避免javascript注入以这种方式验证输入数据:

xssValidate = function(value) {
    var container = $("<u></u>").text(value);
    if($(container).html() != value) return mc.ERROR_INVALID_FORMAT;
}
Run Code Online (Sandbox Code Playgroud)

我已经设法使用上面的代码验证所有文本字段和textareas值,然后再将它们提交给服务器.

Gre*_*reg 6

我认为这对你的用户来说会非常烦人......如果我想输入"this&that"或"11> 7"怎么办?

当你输出它时,你应该做的就是逃避它.

此外,我希望您在服务器和客户端进行验证.