Blame SOURCES/bz1935422-python-pygments-fix-CVE-2021-20270.patch

0c4b27
From f91804ff4772e3ab41f46e28d370f57898700333 Mon Sep 17 00:00:00 2001
0c4b27
From: Georg Brandl <georg@python.org>
0c4b27
Date: Thu, 10 Dec 2020 08:19:21 +0100
0c4b27
Subject: [PATCH] fixes #1625: infinite loop in SML lexer
0c4b27
0c4b27
Reason was a lookahead-only pattern which was included in the state
0c4b27
where the lookahead was transitioning to.
0c4b27
---
0c4b27
 pygments/lexers/ml.py | 12 ++++++------
0c4b27
 2 files changed, 14 insertions(+), 6 deletions(-)
0c4b27
0c4b27
diff --git a/pygments/lexers/ml.py b/pygments/lexers/ml.py
0c4b27
index 8ca8ce3eb..f2ac367c5 100644
0c4b27
--- a/pygments/lexers/ml.py
0c4b27
+++ b/pygments/lexers/ml.py
0c4b27
@@ -142,7 +142,7 @@ def id_callback(self, match):
0c4b27
             (r'#\s+(%s)' % symbolicid_re, Name.Label),
0c4b27
             # Some reserved words trigger a special, local lexer state change
0c4b27
             (r'\b(datatype|abstype)\b(?!\')', Keyword.Reserved, 'dname'),
0c4b27
-            (r'(?=\b(exception)\b(?!\'))', Text, ('ename')),
0c4b27
+            (r'\b(exception)\b(?!\')', Keyword.Reserved, 'ename'),
0c4b27
             (r'\b(functor|include|open|signature|structure)\b(?!\')',
0c4b27
              Keyword.Reserved, 'sname'),
0c4b27
             (r'\b(type|eqtype)\b(?!\')', Keyword.Reserved, 'tname'),
0c4b27
@@ -315,15 +315,14 @@ def id_callback(self, match):
0c4b27
         'ename': [
0c4b27
             include('whitespace'),
0c4b27
 
0c4b27
-            (r'(exception|and)\b(\s+)(%s)' % alphanumid_re,
0c4b27
+            (r'(and\b)(\s+)(%s)' % alphanumid_re,
0c4b27
              bygroups(Keyword.Reserved, Text, Name.Class)),
0c4b27
-            (r'(exception|and)\b(\s*)(%s)' % symbolicid_re,
0c4b27
+            (r'(and\b)(\s*)(%s)' % symbolicid_re,
0c4b27
              bygroups(Keyword.Reserved, Text, Name.Class)),
0c4b27
             (r'\b(of)\b(?!\')', Keyword.Reserved),
0c4b27
+            (r'(%s)|(%s)' % (alphanumid_re, symbolicid_re), Name.Class),
0c4b27
 
0c4b27
-            include('breakout'),
0c4b27
-            include('core'),
0c4b27
-            (r'\S+', Error),
0c4b27
+            default('#pop'),
0c4b27
         ],
0c4b27
 
0c4b27
         'datcon': [
0c4b27
@@ -445,6 +444,7 @@ class OcamlLexer(RegexLexer):
0c4b27
         ],
0c4b27
     }
0c4b27
 
0c4b27
+
0c4b27
 class OpaLexer(RegexLexer):
0c4b27
     """
0c4b27
     Lexer for the Opa language (http://opalang.org).