mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +01:00
Fix possible array-out-of-bounds access, add test.
This commit is contained in:
parent
7f5dd9ab6b
commit
a958a33860
2 changed files with 25 additions and 1 deletions
|
|
@ -65,7 +65,7 @@ function lintContent(content, config) {
|
|||
token.line = lines[token.map[0]];
|
||||
token.lineNumber = token.map[0] + 1;
|
||||
// Trim bottom of token to exclude whitespace lines
|
||||
while (!(lines[token.map[1] - 1].trim())) {
|
||||
while (token.map[1] && !(lines[token.map[1] - 1].trim())) {
|
||||
token.map[1]--;
|
||||
}
|
||||
// Annotate children with lineNumber
|
||||
|
|
|
|||
|
|
@ -189,6 +189,30 @@ module.exports.stringInputLineEndings = function stringInputLineEndings(test) {
|
|||
});
|
||||
};
|
||||
|
||||
module.exports.inputOnlyNewline = function inputOnlyNewline(test) {
|
||||
test.expect(2);
|
||||
var options = {
|
||||
"strings": {
|
||||
"cr": "\r",
|
||||
"lf": "\n",
|
||||
"crlf": "\r\n"
|
||||
},
|
||||
"config": {
|
||||
"default": false
|
||||
}
|
||||
};
|
||||
markdownlint(options, function callback(err, actualResult) {
|
||||
test.ifError(err);
|
||||
var expectedResult = {
|
||||
"cr": {},
|
||||
"lf": {},
|
||||
"crlf": {}
|
||||
};
|
||||
test.deepEqual(actualResult, expectedResult, "Undetected issues.");
|
||||
test.done();
|
||||
});
|
||||
};
|
||||
|
||||
module.exports.defaultTrue = function defaultTrue(test) {
|
||||
test.expect(2);
|
||||
var options = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue