Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion articles.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ the filename of the new article next to it.
- `implied-eval.md` - ~~Implied eval is evil. Pass a function instead of a
string~~
- Unexpected 'in'. Compare with undefined or use the hasOwnProperty method
- Insecure '{a}'
- `Insecure '{a}'` - Insecure ^
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you strike through the name of the article please? It makes it easier to see what's already been written when quickly scrolling through the list.

- `use-isnan.md` - ~~Use the isNaN function to compare with NaN~~
- `leading-decimal.md` - ~~A leading decimal point can be confused with a dot~~
- Missing '{a}'
Expand Down
50 changes: 50 additions & 0 deletions articles/insecure-hat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!---
{
"titles": [
"Insecure ^"
],
"slugs": [
"insecure-hat",
"w059"
Copy link
Owner

Choose a reason for hiding this comment

The 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",
Copy link
Owner

Choose a reason for hiding this comment

The 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"
```
6 changes: 6 additions & 0 deletions authors/hyeend.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "Howard Yeend",
"twitter": "user24",
"github": "user24",
"bio": "JavaScripter"
}