From a9940657c92787a46024d55d18dee8cf37a33d8b Mon Sep 17 00:00:00 2001 From: Isaac Muse Date: Tue, 1 Oct 2024 10:21:24 -0600 Subject: [PATCH] Fix SuperFence pattern should require options to be separated by a space (#2480) --- docs/src/markdown/about/changelog.md | 4 ++++ pymdownx/__meta__.py | 2 +- pymdownx/superfences.py | 4 ++-- tests/test_extensions/test_superfences.py | 11 +++++++++++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/docs/src/markdown/about/changelog.md b/docs/src/markdown/about/changelog.md index 18de57973..e944d76a8 100644 --- a/docs/src/markdown/about/changelog.md +++ b/docs/src/markdown/about/changelog.md @@ -1,5 +1,9 @@ # Changelog +## 10.11.2 + +- **FIX**: SuperFences: Fix a regression where certain patterns could cause a hang. + ## 10.11.1 - **Fix**: SuperFences: Fix regression where an omitted language in conjunction with options in the fenced header diff --git a/pymdownx/__meta__.py b/pymdownx/__meta__.py index 1c3b1fb46..0225b1604 100644 --- a/pymdownx/__meta__.py +++ b/pymdownx/__meta__.py @@ -185,5 +185,5 @@ def parse_version(ver, pre=False): return Version(major, minor, micro, release, pre, post, dev) -__version_info__ = Version(10, 11, 1, "final") +__version_info__ = Version(10, 11, 2, "final") __version__ = __version_info__._get_canonical() diff --git a/pymdownx/superfences.py b/pymdownx/superfences.py index a534bd5e7..0248c8522 100644 --- a/pymdownx/superfences.py +++ b/pymdownx/superfences.py @@ -46,10 +46,10 @@ (?P~{3,}|`{3,}) (?:[ \t]*\.?(?P[\w#.+-]+)(?=[\t ]|$))? # Language (?: - [ \t]*(\{(?P[^\n]*)\}) | # Optional attributes or + [ \t]*(\{(?P[^\n]*)\}) | # Optional attributes or (?P (?: - (?:[ \t]*[a-zA-Z][a-zA-Z0-9_]*(?:=(?P"|').*?(?P=quot))?) # Options + (?:[ \t]*[a-zA-Z][a-zA-Z0-9_]*(?:=(?P"|').*?(?P=quot))?)(?=[\t ]|$) # Options )+ ) )?[ \t]*$ diff --git a/tests/test_extensions/test_superfences.py b/tests/test_extensions/test_superfences.py index ea4714cae..7236387b3 100644 --- a/tests/test_extensions/test_superfences.py +++ b/tests/test_extensions/test_superfences.py @@ -714,6 +714,17 @@ def test_attrs_alternate_form(self): True ) + def test_issue_2479(self): + """Test issue #2479.""" + + self.check_markdown( + """```test_test_test_test_test_test_test_test``` test test.""", + """ +

test_test_test_test_test_test_test_test test test.

+ """, + True + ) + class TestSuperFencesClassesIdsAttrList(util.MdCase): """Test fence ids and classes with attribute lists."""