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

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