This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a commit to branch db/8588
in repository https://gitbox.apache.org/repos/asf/allura.git

commit f689e79b641470bf7ffa694004424b0d3ff39b02
Author: Dave Brondsema <[email protected]>
AuthorDate: Thu Nov 20 17:38:44 2025 -0500

    [#8588] use *+ instead of * (possessive quantifiers) and regular re 
library.  Seems like both *+ are not needed, but doing both for good measure
---
 Allura/allura/lib/markdown_extensions.py | 6 ++----
 Allura/allura/tests/test_globals.py      | 3 ++-
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/Allura/allura/lib/markdown_extensions.py 
b/Allura/allura/lib/markdown_extensions.py
index 93a2904af..4579e1970 100644
--- a/Allura/allura/lib/markdown_extensions.py
+++ b/Allura/allura/lib/markdown_extensions.py
@@ -24,7 +24,6 @@
 
 from urllib.parse import urljoin
 
-import regex
 from tg import config
 from bs4 import BeautifulSoup, MarkupResemblesLocatorWarning
 import html5lib
@@ -49,11 +48,11 @@
 
 # FORGE_LINK_RE copied from markdown pre 3.0's LINK_RE
 # TODO: replace these with newer approach, see ForgeLinkPattern
-NOBRACKET = r'[^\]\[]*'  # if not using regex-as-re-globally, must change "*" 
to {0,50} for performance mitigation
+NOBRACKET = r'[^\]\[]*+'
 BRK = (
     r'\[(' +
     (NOBRACKET + r'(\[')*6 +
-    (NOBRACKET + r'\])*')*6 +
+    (NOBRACKET + r'\])*+')*6 +
     NOBRACKET + r')\]'
 )
 FORGE_LINK_RE = markdown.inlinepatterns.NOIMG + BRK + \
@@ -362,7 +361,6 @@ class ForgeLinkPattern(markdown.inlinepatterns.Pattern):
     def __init__(self, *args, **kwargs):
         self.ext = kwargs.pop('ext')
         super().__init__(*args, **kwargs)
-        self.compiled_re = regex.compile(self.compiled_re.pattern, 
flags=self.compiled_re.flags)
 
     def handleMatch(self, m):
         el = etree.Element('a')
diff --git a/Allura/allura/tests/test_globals.py 
b/Allura/allura/tests/test_globals.py
index c93abed71..04f788ec6 100644
--- a/Allura/allura/tests/test_globals.py
+++ b/Allura/allura/tests/test_globals.py
@@ -601,7 +601,8 @@ def test_markdown_invalid_classes_ids(self):
         assert r == '<div class="markdown_content"><p><i class="fa 
fa-cog">gear icon</i></p></div>'
 
     def test_markdown_extremely_slow(self):
-        # regex-as-re-globally package mitigates this being slow; also see 
`NOBRACKET` comments
+        # this used to be extremely slow due to catastrophic backtracking in 
FORGE_LINK_RE / BRK regex composition
+        # initially mitigated by using the `regex` lib instead of `re` but now 
is mitigated by possessive quantifiers
         g.markdown.convert(inspect.cleandoc('''bonjour, voila ce que j'obtient 
en voulant ajouter un utilisateur a un groupe de sécurite, que ce soit sur un 
groupe pre-existant, ou sur un groupe crée.
     message d'erreur:
 

Reply via email to