mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Add additional validation of lineNumber/range properties in rule onError function.
This commit is contained in:
parent
4c7ffdd335
commit
b55d51cf23
2 changed files with 90 additions and 7 deletions
|
@ -344,8 +344,9 @@ function lintContent(
|
|||
const errors = [];
|
||||
function onError(errorInfo) {
|
||||
if (!errorInfo ||
|
||||
!errorInfo.lineNumber ||
|
||||
!helpers.isNumber(errorInfo.lineNumber)) {
|
||||
!helpers.isNumber(errorInfo.lineNumber) ||
|
||||
(errorInfo.lineNumber < 1) ||
|
||||
(errorInfo.lineNumber > lines.length)) {
|
||||
throwError("lineNumber");
|
||||
}
|
||||
if (errorInfo.detail &&
|
||||
|
@ -360,7 +361,11 @@ function lintContent(
|
|||
(!Array.isArray(errorInfo.range) ||
|
||||
(errorInfo.range.length !== 2) ||
|
||||
!helpers.isNumber(errorInfo.range[0]) ||
|
||||
!helpers.isNumber(errorInfo.range[1]))) {
|
||||
(errorInfo.range[0] < 1) ||
|
||||
!helpers.isNumber(errorInfo.range[1]) ||
|
||||
(errorInfo.range[1] < 1) ||
|
||||
((errorInfo.range[0] + errorInfo.range[1] - 1) >
|
||||
lines[errorInfo.lineNumber - 1].length))) {
|
||||
throwError("range");
|
||||
}
|
||||
errors.push({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue