Skip to content

Fix quadratic-time linebreak parsing - #268

Merged
frostming merged 2 commits into
frostming:masterfrom
absolutely-vivid:fix-219
Jun 1, 2026
Merged

Fix quadratic-time linebreak parsing#268
frostming merged 2 commits into
frostming:masterfrom
absolutely-vivid:fix-219

Conversation

@absolutely-vivid

Copy link
Copy Markdown
Contributor

This is a quick hack to fix issue #219. The regex pattern used for parsing linebreaks combined with the use of re.finditer runs in quadratic time when the parsing input doesn't contain a newline character. By checking for the presence of a newline character the problematic pattern can be short-circuited. Ideally a proper fix would fix the regex pattern itself, but this is a useful fix to have in place until the pattern is fixed.

Fixes #219

This is a quick hack to fix issue frostming#219. The regex pattern used for parsing
linebreaks combined with the use of `re.finditer` runs in quadratic time
when the parsing input doesn't contain a newline character. By checking
for the presence of a newline character the problematic pattern can be
short-circuited. Ideally a proper fix would fix the regex pattern itself,
but this is a useful fix to have in place until the pattern is fixed.

Fixes frostming#219
Comment thread marko/inline.py Outdated
@frostming
frostming merged commit 5fcfc0d into frostming:master Jun 1, 2026
19 checks passed
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.

marko.parse has quadtratic time for some input

2 participants