Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bad handling of consecutive bold words (#541) #545

Merged
merged 1 commit into from
Dec 10, 2023

Conversation

Crozzers
Copy link
Contributor

@Crozzers Crozzers commented Dec 9, 2023

This PR aims to fix #541 while still protecting against #493.

Whilst attempting to fix a ReDOS, I changed the _strong_re to use a greedy pattern, which would consume the lengthy ReDOS input without spending too much processing time on it. However, this also caused the _strong_re to consume multiple bold words as one.

The fix here is to make the regex non-greedy again.

- (\*\*|__)(?=\S)(.*\S)\1
+ (\*\*|__)(?=\S)(.+?[*_]?)(?<=\S)\1

This should match the opening syntax followed by a non-whitespace char, one or more characters followed by an optional <em> closer, and then the closing syntax preceeded by a non-whitespace char.

@nicholasserra
Copy link
Collaborator

Thanks! Will prob do another release after this.

@nicholasserra nicholasserra merged commit 0fa9739 into trentm:master Dec 10, 2023
18 checks passed
fghaas added a commit to fghaas/python-markdown2 that referenced this pull request Dec 11, 2023
Update the changelog in relation to the fix applied in
078f76a (PR trentm#545).
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.

Bad handling of two consecutive bold words
2 participants