Skip to content

[markdown] Fix quadratic scan-and-rewind in inline link parsing - #2730

Closed
jonasfj wants to merge 3 commits into
mainfrom
markdown_inline_link_scan
Closed

jonasfj wants to merge 3 commits into
mainfrom
markdown_inline_link_scan

Conversation

@jonasfj

@jonasfj jonasfj commented Oct 27, 2026

Copy link
Copy Markdown
Member

Reject unescaped < inside bracketed inline link destinations, unescaped ( inside paren-delimited link titles, and unbalanced or deeply nested parentheses in bare inline link destinations per CommonMark §6.3.

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

PR Health

License Headers ✔️
// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

Files
no missing headers

All source files should start with a license header.

Unrelated files missing license headers
Files
pkgs/html/test/differential_test.dart
pkgs/html/test/dom_parsing_test.dart
pkgs/html/test/mxss_test.dart
pkgs/html/test/noah_ark_clause_limit_test.dart

This check can be disabled by tagging the PR with skip-license-check.

Breaking changes ✔️
Package Change Current Version New Version Needed Version Looking good?
markdown Non-Breaking 7.3.1 7.4.1-wip 7.4.1-wip ✔️

This check can be disabled by tagging the PR with skip-breaking-check.

Unused Dependencies ✔️
Package Status
markdown ✔️ All dependencies utilized correctly.

For details on how to fix these, see dependency_validator.

This check can be disabled by tagging the PR with skip-unused-dependencies-check.

Coverage ✔️
File Coverage
pkgs/markdown/lib/src/inline_syntaxes/link_syntax.dart 💚 99 % ⬆️ 0 %

This check for test coverage is informational (issues shown here will not fail the PR).

This check can be disabled by tagging the PR with skip-coverage-check.

API leaks ✔️

The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.

Package Leaked API symbol Leaking sources

This check can be disabled by tagging the PR with skip-leaking-check.

Changelog Entry ✔️
Package Changed Files

Changes to files need to be accounted for in their respective changelogs.

This check can be disabled by tagging the PR with skip-changelog-check (for example, for non-user-visible changes when the package version is already at -wip).

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request fixes a performance issue where repeated unclosed inline link destinations and titles in LinkSyntax caused quadratic scan-and-rewind times. It addresses this by limiting parentheses nesting, rejecting unescaped < characters within bracketed destinations, and adding early exits for invalid states. A regression test has been added to verify the performance improvement. I have no feedback to provide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant