[PR #262] [CLOSED] Fix NPE with wrapped links #830

Closed
opened 2026-03-03 01:30:22 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/DavidAnson/markdownlint/pull/262
Author: @miffels
Created: 3/2/2020
Status: Closed

Base: masterHead: patch-1


📝 Commits (1)

  • c09a670 Fix NPE with wrapped links

📊 Changes

1 file changed (+1 additions, -1 deletions)

View changed files

📝 lib/md039.js (+1 -1)

📄 Description

The regex change addresses an issue when due to automated line wrapping or other f-ups links get wrapped like this:

* This is a badly wrapped [ Link with a leading space
     ](https://acme.com)

Before the change, the failed match would result in an NPE:

root/node_modules/markdownlint/lib/markdownlint.js:648
      throw error;
      ^

TypeError: Cannot read property 'index' of null
    at root/node_modules/markdownlint/lib/md039.js:32:34
    at Array.forEach (<anonymous>)
    at root/node_modules/markdownlint/lib/md039.js:20:16
    at forToken (root/node_modules/markdownlint/helpers/helpers.js:151:7)
    at Array.forEach (<anonymous>)
    at filterTokens (root/node_modules/markdownlint/helpers/helpers.js:149:17)
    at Object.MD039 [as function] (root/node_modules/markdownlint/lib/md039.js:14:5)
    at forRule (root/node_modules/markdownlint/lib/markdownlint.js:466:20)
    at Array.forEach (<anonymous>)
    at lintContent (root/node_modules/markdownlint/lib/markdownlint.js:512:14)

Alternatively, one could add error handling to ensure the regex actually matches:

// Before line 32
if(!match) console.error("Could not match " + line");

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/DavidAnson/markdownlint/pull/262 **Author:** [@miffels](https://github.com/miffels) **Created:** 3/2/2020 **Status:** ❌ Closed **Base:** `master` ← **Head:** `patch-1` --- ### 📝 Commits (1) - [`c09a670`](https://github.com/DavidAnson/markdownlint/commit/c09a6700223cdbda2ea562b5669fb12bcd731186) Fix NPE with wrapped links ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `lib/md039.js` (+1 -1) </details> ### 📄 Description The regex change addresses an issue when due to automated line wrapping or other f-ups links get wrapped like this: ```markdown * This is a badly wrapped [ Link with a leading space ](https://acme.com) ``` Before the change, the failed match would result in an NPE: ``` root/node_modules/markdownlint/lib/markdownlint.js:648 throw error; ^ TypeError: Cannot read property 'index' of null at root/node_modules/markdownlint/lib/md039.js:32:34 at Array.forEach (<anonymous>) at root/node_modules/markdownlint/lib/md039.js:20:16 at forToken (root/node_modules/markdownlint/helpers/helpers.js:151:7) at Array.forEach (<anonymous>) at filterTokens (root/node_modules/markdownlint/helpers/helpers.js:149:17) at Object.MD039 [as function] (root/node_modules/markdownlint/lib/md039.js:14:5) at forRule (root/node_modules/markdownlint/lib/markdownlint.js:466:20) at Array.forEach (<anonymous>) at lintContent (root/node_modules/markdownlint/lib/markdownlint.js:512:14) ``` Alternatively, one could add error handling to ensure the regex actually matches: ```javascript // Before line 32 if(!match) console.error("Could not match " + line"); ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-03 01:30:22 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/markdownlint#830
No description provided.