Skip to content

Commit

Permalink
Merge pull request #531 from Crozzers/repair_ReDoS
Browse files Browse the repository at this point in the history
Repair ReDoS (issue #493, PR #494)
  • Loading branch information
nicholasserra committed Oct 9, 2023
2 parents d61a7e1 + c88dd6e commit 191b660
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/markdown2.py
Expand Up @@ -2332,10 +2332,10 @@ def _do_tg_spoiler(self, text):
text = self._tg_spoiler_re.sub(r"<tg-spoiler>\1</tg-spoiler>", text)
return text

_strong_re = re.compile(r"(\*\*|__)(?=\S)(.+?[*_]*)(?<=\S)\1", re.S)
_em_re = r"(\*|_)(?=\S)(.+?)(?<=\S)\1"
_code_friendly_strong_re = re.compile(r"\*\*(?=\S)(.+?[*_]*)(?<=\S)\*\*", re.S)
_code_friendly_em_re = r"\*(?=\S)(.+?)(?<=\S)\*"
_strong_re = re.compile(r"(\*\*|__)(?=\S)(.*\S)\1", re.S)
_em_re = r"(\*|_)(?=\S)(.*?\S)\1"
_code_friendly_strong_re = re.compile(r"\*\*(?=\S)(.+?[*_]*)\*\*", re.S)
_code_friendly_em_re = r"\*(?=\S)(.+?)\*"
def _do_italics_and_bold(self, text):
if self.extras.get('middle-word-em', True) is False:
code_friendly_em_re = r'(?<=\b)%s(?=\b)' % self._code_friendly_em_re
Expand Down

0 comments on commit 191b660

Please sign in to comment.