Skip to content

Conversation

@btucker
Copy link

@btucker btucker commented Dec 28, 2025

The updatepos() override was resetting the parser position to 0, causing infinite loops when multiple bogus/unclosed comments appeared in the input (e.g., </ followed by non-standard characters or <!-- ). Now tracks the position of the triggering < and advances past it instead of rewinding to the start of the buffer.

Fixes #1578

@btucker btucker force-pushed the fix/double-comment-bug branch from 6ab1ab3 to e6cabdc Compare December 28, 2025 01:00
The updatepos() override was resetting the parser position to 0,
causing infinite loops when multiple bogus/unclosed comments
appeared in the input (e.g., `</` or `<!--` followed by non-standard
characters). Now tracks the position of the triggering `<` and
advances past it instead of rewinding to the start of the buffer.

Fixes Python-Markdown#1578
@btucker btucker force-pushed the fix/double-comment-bug branch from e6cabdc to 94aafb7 Compare December 28, 2025 01:16
@facelessuser
Copy link
Collaborator

Good catch! One question though, I'm not following how this fixed this case:

markdown.markdown("`</` and `</`")

It seems the reset logic is only triggered when hitting -->. In the above example, that isn't happening. I'm sure I'm just missing something.

@facelessuser
Copy link
Collaborator

Never mind, it's != '-->' 🤦🏻

Copy link
Collaborator

@facelessuser facelessuser left a comment

Choose a reason for hiding this comment

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

LGTM. Changelog should get updated, though.

@btucker
Copy link
Author

btucker commented Dec 28, 2025

Yeah, exactly. </ being treated as the start of a comment was news to me.

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.

Infinite loop when inline code contains two or more </

2 participants