Permalink
Browse files

Don't warn about insecure ^ when regexp is set.

This option was supposed to be only about insecure '.' and lots of
people seem to thnk that warning about ^ is unwarranted.

Closes GH-555.
  • Loading branch information...
1 parent 4f1005d commit 53e862e114cf2bb21b298780bf1c61330333529c @valueof valueof committed Aug 29, 2012
Showing with 3 additions and 11 deletions.
  1. +1 −4 jshint.js
  2. +2 −7 tests/unit/options.js
View
5 jshint.js
@@ -1620,10 +1620,7 @@ unclosedString: for (;;) {
c = s.charAt(l);
if (c === "^") {
l += 1;
- if (option.regexp) {
- warningAt("Insecure '{a}'.",
- line, from + l, c);
- } else if (s.charAt(l) === "]") {
+ if (s.charAt(l) === "]") {
errorAt("Unescaped '{a}'.",
line, from + l, "^");
}
View
9 tests/unit/options.js
@@ -836,9 +836,8 @@ exports.globalstrict = function () {
/** Option `regexp` disallows the use of . and [^...] in regular expressions. */
exports.regexp = function () {
var code = [
- 'var a = /hey/;'
- , 'var a = /h.ey/;'
- , 'var a = /h[^...]/;'
+ 'var a = /hey/;',
+ 'var a = /h.ey/;'
];
for (var i = 0, st; st = code[i]; i += 1) {
@@ -850,10 +849,6 @@ exports.regexp = function () {
TestRun()
.addError(1, "Insecure '.'.")
.test(code[1], { regexp: true });
-
- TestRun()
- .addError(1, "Insecure '^'.")
- .test(code[2], { regexp: true });
};
/** Option `laxbreak` allows you to insert newlines before some operators. */

0 comments on commit 53e862e

Please sign in to comment.