Skip to content

fix(parser): fail fast on rules that don't advance state (infinite loop guard) - #443

Open
inchang-ing wants to merge 1 commit into
executablebooks:masterfrom
inchang-ing:fix/guard-nonadvancing-rule
Open

inchang-ing wants to merge 1 commit into
executablebooks:masterfrom
inchang-ing:fix/guard-nonadvancing-rule

Conversation

@inchang-ing

Copy link
Copy Markdown

@e:/zcode-PR/.trash/pr-body-markdown-it-py-441.md

…op guard)

Port markdown-it JS's guard (since 13.0.2): raise RuntimeError when a
block/inline rule reports a match without advancing state.line /
state.pos, instead of looping forever and exhausting memory.

A buggy plugin rule that returns True without advancing made parse()
hang indefinitely (e.g. texmath/amsmath plugin bugs, mdit-py-plugins#156
and executablebooks#117). Built-in rules always advance, so this only affects already
broken plugins, which now fail with a clear message.

Fixes executablebooks#441.

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.

1 participant