Why is [^ ...] in / RegExp / not protected?

jslint detects my following code as unsafe:

/([^\n]+)([\n\s]*)/g

      

Later I found out that there is a lint option:

"and [^ ...] in / RegExp /"

which you can find here here

Why is it not safe?

+3


source to share


1 answer


The problem is with the character [^ ...] you resolve practically in your regex and jshint detects a security threat.

This is what the jslint docs says about [^ ...]:



true if. and [^ ...] must be allowed in RegExp literals. They match more material than one would expect, allowing attackers to obfuscate the Applications. These forms should not be used when checking in secure applications.

+2


source







All Articles