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

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