-
Notifications
You must be signed in to change notification settings - Fork 35
Insecure ^ #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Insecure ^ #29
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<!--- | ||
{ | ||
"titles": [ | ||
"Insecure ^" | ||
], | ||
"slugs": [ | ||
"insecure-hat", | ||
"w059" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. w059 in JSHint is "Avoid arguments.{a}". I don't think JSHint has an equivalent to this message. |
||
], | ||
"linters": [ | ||
"jslint", | ||
"jshint", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As above, I don't think JSHint has an equivalent to this error. |
||
"eslint" | ||
], | ||
"author": "hyeend" | ||
} | ||
--> | ||
|
||
### When do I get this error? | ||
|
||
The "Insecure ^" error is thrown when JSLint encounters a regular expression containing the negation operator ^. | ||
|
||
JSLint will only raise this warning if the `regexp` option is set to true. | ||
<!--- | ||
{ | ||
"linter": "jslint" | ||
} | ||
--> | ||
```javascript | ||
"Hello Bob".match(/[^a-z]/g); | ||
// Returns [ 'H', ' ', 'B' ] | ||
``` | ||
|
||
### Why do I get this error? | ||
|
||
This error is raised to highlight **potentially dangerous matches** such as some special control characters. For example, an attacker might include a unicode character or an EOL character, which would get matched by the over-zealous not and may cause your application to respond in unexpected ways. | ||
|
||
It is safe to ignore or disable this error if you are only matching in order to dispose of the matched characters, for example: | ||
|
||
<!--- | ||
{ | ||
"linter": "jslint" | ||
} | ||
--> | ||
```javascript | ||
/*jslint regexp:true*/ // Allow ^ because we're only using it to remove the matching characters | ||
"Hello Bob".replace(/[^A-Z]/g, ""); | ||
/*jslint regexp:false*/ | ||
// Returns "HB" | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "Howard Yeend", | ||
"twitter": "user24", | ||
"github": "user24", | ||
"bio": "JavaScripter" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you
strike throughthe name of the article please? It makes it easier to see what's already been written when quickly scrolling through the list.