JSLint reports Insecure '^' for the following line. Why is that? Or is it just going to complain any time I want to negate a character class?
// remove all non alphanumeric, comma and dash characters "!$7s-gd,&j5d-a#".replace(/[^\w,\-]/g, '');
It only will do this if you have the option selected at the bottom:
Disallow insecure . and [^...] in /RegExp/
From the docs:
true if . and [^...] should not be allowed in RegExp literals. These forms should not be used when validating in secure applications.
So the answer your question, if you start a regex with ^
and it's checked, yes it'll throw the error every time. The issue is with unicode characters, you're allowing pretty much anything in there and there's potential for security issues, or validation bypassing issues. Instead of disallowing something (which can be bypassed), allow only what characters are valid.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With