sách gpt4 ăn đã đi

javascript - 正则表达式中的 JSLint "insecure ^"

In lại 作者:IT王子 更新时间:2023-10-29 03:06:20 25 4
mua khóa gpt4 giày nike

JSLint 报告以下行的不安全“^”。这是为什么?还是只要我想否定一个字符类,它就会提示?

// remove all non alphanumeric, comma and dash characters
"!$7s-gd,&j5d-a#".replace(/[^\w,\-]/g, '');

câu trả lời hay nhất

只有在底部选择了选项时才会执行此操作:

Disallow insecure . and [^...] in /RegExp/

từ the docs :

true if . and [^...] should not be allowed in RegExp literals. These forms should not be used when validating in secure applications.

所以回答你的问题,如果你用 ^ 开始一个正则表达式并且它被选中,是的,它每次都会抛出错误。问题在于 unicode 字符,您几乎允许其中的任何内容,并且可能存在安全问题或验证绕过问题。而不是禁止某些东西(可以绕过),只允许哪些字符是有效的。

关于javascript - 正则表达式中的 JSLint "insecure ^",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4109214/

25 4 0
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress