From 57c76c83ebd70f63e2bf0356fe1e52405d828049 Mon Sep 17 00:00:00 2001 From: Crozzers Date: Thu, 18 Dec 2025 23:04:50 +0000 Subject: [PATCH] Fix #668 --- lib/markdown2.py | 4 +++- test/test_redos.py | 24 +++++++++++++++--------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/lib/markdown2.py b/lib/markdown2.py index 8d073cad..23300ac7 100755 --- a/lib/markdown2.py +++ b/lib/markdown2.py @@ -2574,7 +2574,9 @@ class GFMItalicAndBoldProcessor(Extra): def run(self, text): nesting = True - while nesting: + orig_text = "" + while nesting and orig_text != _hash_text(text): + orig_text = _hash_text(text) nesting = False opens = {'*': [], '_': []} diff --git a/test/test_redos.py b/test/test_redos.py index 180ce931..fb1147e0 100644 --- a/test/test_redos.py +++ b/test/test_redos.py @@ -37,17 +37,23 @@ def issue_633(): # https://github.com/trentm/python-markdown2/issues/633 return '