好像JSlint最近添加了这个选项:
“在/RegExp/中容忍 . 和 [^...]”。
为什么在正则表达式中使用 .
或 ^
不好?
最佳答案
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 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/