fix: fix infinite loop for indented code blank line#3947
Merged
UziTech merged 4 commits intomarkedjs:masterfrom Apr 18, 2026
Merged
fix: fix infinite loop for indented code blank line#3947UziTech merged 4 commits intomarkedjs:masterfrom
UziTech merged 4 commits intomarkedjs:masterfrom
Conversation
|
@UziTech is attempting to deploy a commit to the MarkedJS Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces infinite loop detection in the Lexer by monitoring the length of the source string during iteration. It also refactors error handling for infinite loops into a dedicated private method. Additionally, the trimTrailingBlankLines helper was updated to use a regex test for blank lines, and a new ReDoS test case was added. I have no feedback to provide.
styfle
approved these changes
Apr 18, 2026
github-actions Bot
pushed a commit
that referenced
this pull request
Apr 18, 2026
## [18.0.2](v18.0.1...v18.0.2) (2026-04-18) ### Bug Fixes * fix infinite loop for indented code blank line ([#3947](#3947)) ([58a52e8](58a52e8))
Logiclayer1111
pushed a commit
to Logiclayer1111/marked
that referenced
this pull request
Apr 20, 2026
## [18.0.2](markedjs/marked@v18.0.1...v18.0.2) (2026-04-18) ### Bug Fixes * fix infinite loop for indented code blank line ([#3947](markedjs/marked#3947)) ([f2b378c](markedjs/marked@f2b378c))
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Marked version: v18.0.1
Description
Fix infinite loop in indented code with only whitespace.
In v18 we introduced a change to indented code that removes trailing blank lines, but the way we detect blank lines as any whitespace we can create empty token if the code is only whitespace (e.g. '\v' vertical tab). Currently we will just keep creating empty indented code tokens until we run out of memory.
Thanks for finding this @MaanVader
This PR checks for infinite loops and throws an error if found. It also defines a blank line in indented code tokens as only containing space or tab like it should. If the indented code block only has tabs or spaces it is not an indented code block according to CommonMark.
Contributor
Committer
In most cases, this should be a different person than the contributor.