JSLint reports “Insecure ^” for my regex — what does that mean?

前端 未结 3 1938

I\'m trying to get my Javascript code 100% JSLint clean.

I\'ve got a regular expression:

 linkRgx = /https?:\\/\\/[^\\s;|\\\\*\'\"!,()<>]+/g;
<         


        
3条回答
  •  抹茶落季
    2020-11-29 11:58

    (answering my own question) I did some digging... JSLint documentation says:

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

    What I have done is disable the JSLint error for the offending line (as I'm not dealing with needing to be secure from potentially malicious user input:

    /*jslint regexp: false*/
    .... Javascript statement(s) ....
    /*jslint regexp: true*/
    

提交回复
热议问题