javascript - 容忍 。和 [^...] 在/RegExp/

标签 javascript jslint

好像JSlint最近添加了这个选项:

“在/RegExp/中容忍 . 和 [^...]”。

为什么在正则表达式中使用 .^ 不好?

最佳答案

来自 the JSLint documentation :

They match more material than might be expected, allowing attackers to confuse applications. These forms should not be used when validating in secure applications.

这似乎是基于一种哲学,即明确允许的内容,而不是使用 允许任何内容(包括多字节和非打印字符)。 或允许除 x、y 和 z 之外的任何内容( [^…] 表示)

来自 the JSLint mailing list :

The rationale behind this is that some people don't understand what . and [^...] mean in regular expressions, so it causes their code to either accept something as valid when it isn't, or reject something that's valid.

关于javascript - 容忍 。和 [^...] 在/RegExp/,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8498267/

相关文章:

javascript - 如何移植 iOS 索引文件以响应原生到 android

javascript - 选择后使 <select> 对象保持展开状态

javascript - ASP.NET MVC 5 - jQuery AJAX 有效,Fetch API 无效

javascript - 用js设置div的数据属性

javascript - JavaScript 中的命名空间技术在 JSLint 中存在问题

javascript - JSLint 将 'window' 作为全局变量的问题

javascript - JS : How to fix "Expected ' )' to match ' (' from line 4 and instead saw ' ='." JSLint error

javascript - JSLint - 如何修复 ActiveXObject 在定义之前使用的错误

javascript - JSlint 警告 `redeclaration of var counter` 是否必要?

AngularJS 服务中的 Javascript 显示模块模式不起作用