Skip to content

fix: stop parsing when plugin rules do not advance - #444

Open
rupayon123 wants to merge 1 commit into
executablebooks:masterfrom
rupayon123:fix/non-advancing-plugin-rules
Open

rupayon123 wants to merge 1 commit into
executablebooks:masterfrom
rupayon123:fix/non-advancing-plugin-rules

Conversation

@rupayon123

Copy link
Copy Markdown

Summary

Fail fast when a block or inline rule reports a match without advancing the parser state. Previously, such a plugin could make parse() loop forever and continually allocate tokens. The guards cover block parsing, inline parsing, and inline validation (skipToken), following the behavior of markdown-it's JavaScript implementation.

Closes #441.

Validation

  • Reproduced the reported block and inline hangs before the fix in child processes; both were stopped after 0.5 seconds.
  • Focused progress and plugin tests: 15 passed.
  • Full tests/ suite: 1,035 passed.
  • Ruff 0.16.7 check and format check passed; git diff --check passed.
  • The repository's benchmarking directory was not included because the reused test environment lacks its pytest-benchmark plugin; the configured tests/ suite passed.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Guard against rules that don't advance state.line / state.pos, as markdown-it JS does

1 participant