作者:手机用户2502898443 | 来源:互联网 | 2023-05-18 05:53
IhavealineofcodethatgetsthefollowingerrorwhenrunthroughJSLint:我有一行代码,在使用JSLint时得到如下错误
I have a line of code that gets the following error when run through JSLint:
我有一行代码,在使用JSLint时得到如下错误:
Lint at line 604 character 48: Insecure '^'.
numExp = parseInt(val[1].replace(/[^\-+\d]/g, ""), 10);
This error seems to refer to the following description from JSLint's option page:
这个错误似乎引用了JSLint的选项页面的以下描述:
"true if . and [^...] should not be allowed in RegExp literals.
These forms should not be used when validating in secure applications."
I don't quite understand how a client-side Javascript application can really be considered secure. Even with the most airtight regex, it's still possible to fire up something like firebug and change the variable anyway. The real input validation should be done on the server, and the client browser should probably stick with validation that will handle the abuse of your average user.
我不太理解客户端Javascript应用程序是如何被认为是安全的。即使使用了最严密的regex,仍然可以启动firebug之类的东西并修改变量。真正的输入验证应该在服务器上完成,客户端浏览器可能应该坚持使用验证来处理普通用户的滥用。
Is it safe to ignore this error? Am I missing an angle here where my application will be insecure because of client-side input validation?
忽略这个错误安全吗?在这里,我是否缺少一个角度,使我的应用程序由于客户端输入验证而变得不安全?
2 个解决方案