-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests: Added new pattern check for octal escapes (#2189)
This adds a new pattern check to disallow octal character escapes (e.g. `\12`).
- Loading branch information
1 parent
5450e24
commit 81e1c3d
Showing
6 changed files
with
90 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,42 @@ | ||
Prism.languages['shell-session'] = { | ||
'command': { | ||
pattern: /\$(?:[^\r\n'"<]|(["'])(?:\\[\s\S]|\$\([^)]+\)|`[^`]+`|(?!\1)[^\\])*\1|(?:^|[^<])<<\s*["']?(?:\w+?)["']?\s*(?:\r\n?|\n)(?:[\s\S])*?(?:\r\n?|\n)\3)+/, | ||
inside: { | ||
'bash': { | ||
pattern: /(\$\s*)[\s\S]+/, | ||
lookbehind: true, | ||
alias: 'language-bash', | ||
inside: Prism.languages.bash | ||
}, | ||
'sh': { | ||
pattern: /^\$/, | ||
alias: 'important' | ||
(function (Prism) { | ||
|
||
// CAREFUL! | ||
// The following patterns are concatenated, so the group referenced by a back reference is non-obvious! | ||
|
||
var strings = [ | ||
// normal string | ||
// 1 capturing group | ||
/(["'])(?:\\[\s\S]|\$\([^)]+\)|`[^`]+`|(?!\1)[^\\])*\1/.source, | ||
|
||
// here doc | ||
// 1 capturing group | ||
/<<-?\s*(\w+?)\s*(?:\r?\n|\r)[\s\S]*?(?:\r?\n|\r)\2/.source, | ||
|
||
// here doc quoted | ||
// 2 capturing group | ||
/<<-?\s*(["'])(\w+)\3\s*(?:\r?\n|\r)[\s\S]*?(?:\r?\n|\r)\4/.source | ||
].join('|'); | ||
|
||
Prism.languages['shell-session'] = { | ||
'command': { | ||
pattern: RegExp(/\$(?:[^\r\n'"<]|<<str>>)+/.source.replace(/<<str>>/g, strings)), | ||
inside: { | ||
'bash': { | ||
pattern: /(\$\s*)[\s\S]+/, | ||
lookbehind: true, | ||
alias: 'language-bash', | ||
inside: Prism.languages.bash | ||
}, | ||
'sh': { | ||
pattern: /^\$/, | ||
alias: 'important' | ||
} | ||
} | ||
}, | ||
'output': { | ||
pattern: /.(?:.*(?:\r\n?|\n|.$))*/ | ||
// output highlighting? | ||
} | ||
}, | ||
'output': { | ||
pattern: /.(?:.*(?:\r\n?|\n|.$))*/ | ||
// output highlighting? | ||
} | ||
} | ||
}; | ||
|
||
}(Prism)); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters