|
|
145c2a |
From 2e7e8c4a7b318f4032493773732754e418279a14 Mon Sep 17 00:00:00 2001
|
|
|
145c2a |
From: Georg Brandl <georg@python.org>
|
|
|
145c2a |
Date: Mon, 11 Jan 2021 09:46:34 +0100
|
|
|
145c2a |
Subject: [PATCH] Fix several exponential/cubic complexity regexes found by Ben
|
|
|
145c2a |
Caller/Doyensec
|
|
|
145c2a |
|
|
|
145c2a |
---
|
|
|
145c2a |
pygments/lexers/archetype.py | 2 +-
|
|
|
145c2a |
pygments/lexers/factor.py | 4 ++--
|
|
|
145c2a |
pygments/lexers/jvm.py | 1 -
|
|
|
145c2a |
pygments/lexers/matlab.py | 6 +++---
|
|
|
145c2a |
pygments/lexers/objective.py | 4 ++--
|
|
|
145c2a |
pygments/lexers/templates.py | 2 +-
|
|
|
145c2a |
pygments/lexers/varnish.py | 2 +-
|
|
|
145c2a |
8 files changed, 14 insertions(+), 12 deletions(-)
|
|
|
145c2a |
|
|
|
145c2a |
diff --git a/pygments/lexers/archetype.py b/pygments/lexers/archetype.py
|
|
|
145c2a |
index 65046613d..26f5ea8c9 100644
|
|
|
145c2a |
--- a/pygments/lexers/archetype.py
|
|
|
145c2a |
+++ b/pygments/lexers/archetype.py
|
|
|
145c2a |
@@ -58,7 +58,7 @@ class AtomsLexer(RegexLexer):
|
|
|
145c2a |
(r'P((\d*(\.\d+)?[YyMmWwDd]){1,3}(T(\d*(\.\d+)?[HhMmSs]){,3})?|'
|
|
|
145c2a |
r'T(\d*(\.\d+)?[HhMmSs]){,3})', Literal.Date),
|
|
|
145c2a |
(r'[+-]?(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+', Number.Float),
|
|
|
145c2a |
- (r'[+-]?(\d+)*\.\d+%?', Number.Float),
|
|
|
145c2a |
+ (r'[+-]?\d*\.\d+%?', Number.Float),
|
|
|
145c2a |
(r'0x[0-9a-fA-F]+', Number.Hex),
|
|
|
145c2a |
(r'[+-]?\d+%?', Number.Integer),
|
|
|
145c2a |
],
|
|
|
145c2a |
diff --git a/pygments/lexers/factor.py b/pygments/lexers/factor.py
|
|
|
145c2a |
index be7b30dff..9200547f9 100644
|
|
|
145c2a |
--- a/pygments/lexers/factor.py
|
|
|
145c2a |
+++ b/pygments/lexers/factor.py
|
|
|
145c2a |
@@ -265,7 +265,7 @@ class FactorLexer(RegexLexer):
|
|
|
145c2a |
(r'(?:<PRIVATE|PRIVATE>)\s', Keyword.Namespace),
|
|
|
145c2a |
|
|
|
145c2a |
# strings
|
|
|
145c2a |
- (r'"""\s+(?:.|\n)*?\s+"""', String),
|
|
|
145c2a |
+ (r'"""\s(?:.|\n)*?\s"""', String),
|
|
|
145c2a |
(r'"(?:\\\\|\\"|[^"])*"', String),
|
|
|
145c2a |
(r'\S+"\s+(?:\\\\|\\"|[^"])*"', String),
|
|
|
145c2a |
(r'CHAR:\s+(?:\\[\\abfnrstv]|[^\\]\S*)\s', String.Char),
|
|
|
145c2a |
@@ -322,7 +322,7 @@ class FactorLexer(RegexLexer):
|
|
|
145c2a |
'slots': [
|
|
|
145c2a |
(r'\s+', Text),
|
|
|
145c2a |
(r';\s', Keyword, '#pop'),
|
|
|
145c2a |
- (r'(\{\s+)(\S+)(\s+[^}]+\s+\}\s)',
|
|
|
145c2a |
+ (r'(\{\s+)(\S+)(\s[^}]+\s\}\s)',
|
|
|
145c2a |
bygroups(Text, Name.Variable, Text)),
|
|
|
145c2a |
(r'\S+', Name.Variable),
|
|
|
145c2a |
],
|
|
|
145c2a |
diff --git a/pygments/lexers/jvm.py b/pygments/lexers/jvm.py
|
|
|
145c2a |
index 62dfd45e5..9a9397c2d 100644
|
|
|
145c2a |
--- a/pygments/lexers/jvm.py
|
|
|
145c2a |
+++ b/pygments/lexers/jvm.py
|
|
|
145c2a |
@@ -981,7 +981,6 @@ class CeylonLexer(RegexLexer):
|
|
|
145c2a |
(r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'),
|
|
|
145c2a |
(r'"(\\\\|\\[^\\]|[^"\\])*"', String),
|
|
|
145c2a |
(r"'\\.'|'[^\\]'|'\\\{#[0-9a-fA-F]{4}\}'", String.Char),
|
|
|
145c2a |
- (r'".*``.*``.*"', String.Interpol),
|
|
|
145c2a |
(r'(\.)([a-z_]\w*)',
|
|
|
145c2a |
bygroups(Operator, Name.Attribute)),
|
|
|
145c2a |
(r'[a-zA-Z_]\w*:', Name.Label),
|
|
|
145c2a |
diff --git a/pygments/lexers/matlab.py b/pygments/lexers/matlab.py
|
|
|
145c2a |
index 4823c6a7e..578848623 100644
|
|
|
145c2a |
--- a/pygments/lexers/matlab.py
|
|
|
145c2a |
+++ b/pygments/lexers/matlab.py
|
|
|
145c2a |
@@ -137,7 +137,7 @@ class MatlabLexer(RegexLexer):
|
|
|
145c2a |
(r'.', Comment.Multiline),
|
|
|
145c2a |
],
|
|
|
145c2a |
'deffunc': [
|
|
|
145c2a |
- (r'(\s*)(?:(.+)(\s*)(=)(\s*))?(.+)(\()(.*)(\))(\s*)',
|
|
|
145c2a |
+ (r'(\s*)(?:(\S+)(\s*)(=)(\s*))?(.+)(\()(.*)(\))(\s*)',
|
|
|
145c2a |
bygroups(Whitespace, Text, Whitespace, Punctuation,
|
|
|
145c2a |
Whitespace, Name.Function, Punctuation, Text,
|
|
|
145c2a |
Punctuation, Whitespace), '#pop'),
|
|
|
145c2a |
@@ -638,7 +638,7 @@ class OctaveLexer(RegexLexer):
|
|
|
145c2a |
(r"[^']*'", String, '#pop'),
|
|
|
145c2a |
],
|
|
|
145c2a |
'deffunc': [
|
|
|
145c2a |
- (r'(\s*)(?:(.+)(\s*)(=)(\s*))?(.+)(\()(.*)(\))(\s*)',
|
|
|
145c2a |
+ (r'(\s*)(?:(\S+)(\s*)(=)(\s*))?(.+)(\()(.*)(\))(\s*)',
|
|
|
145c2a |
bygroups(Whitespace, Text, Whitespace, Punctuation,
|
|
|
145c2a |
Whitespace, Name.Function, Punctuation, Text,
|
|
|
145c2a |
Punctuation, Whitespace), '#pop'),
|
|
|
145c2a |
@@ -710,7 +710,7 @@ class ScilabLexer(RegexLexer):
|
|
|
145c2a |
(r'.', String, '#pop'),
|
|
|
145c2a |
],
|
|
|
145c2a |
'deffunc': [
|
|
|
145c2a |
- (r'(\s*)(?:(.+)(\s*)(=)(\s*))?(.+)(\()(.*)(\))(\s*)',
|
|
|
145c2a |
+ (r'(\s*)(?:(\S+)(\s*)(=)(\s*))?(.+)(\()(.*)(\))(\s*)',
|
|
|
145c2a |
bygroups(Whitespace, Text, Whitespace, Punctuation,
|
|
|
145c2a |
Whitespace, Name.Function, Punctuation, Text,
|
|
|
145c2a |
Punctuation, Whitespace), '#pop'),
|
|
|
145c2a |
diff --git a/pygments/lexers/objective.py b/pygments/lexers/objective.py
|
|
|
145c2a |
index 34e4062f6..38ac9bb05 100644
|
|
|
145c2a |
--- a/pygments/lexers/objective.py
|
|
|
145c2a |
+++ b/pygments/lexers/objective.py
|
|
|
145c2a |
@@ -261,11 +261,11 @@ class LogosLexer(ObjectiveCppLexer):
|
|
|
145c2a |
'logos_classname'),
|
|
|
145c2a |
(r'(%hook|%group)(\s+)([a-zA-Z$_][\w$]+)',
|
|
|
145c2a |
bygroups(Keyword, Text, Name.Class)),
|
|
|
145c2a |
- (r'(%config)(\s*\(\s*)(\w+)(\s*=\s*)(.*?)(\s*\)\s*)',
|
|
|
145c2a |
+ (r'(%config)(\s*\(\s*)(\w+)(\s*=)(.*?)(\)\s*)',
|
|
|
145c2a |
bygroups(Keyword, Text, Name.Variable, Text, String, Text)),
|
|
|
145c2a |
(r'(%ctor)(\s*)(\{)', bygroups(Keyword, Text, Punctuation),
|
|
|
145c2a |
'function'),
|
|
|
145c2a |
- (r'(%new)(\s*)(\()(\s*.*?\s*)(\))',
|
|
|
145c2a |
+ (r'(%new)(\s*)(\()(.*?)(\))',
|
|
|
145c2a |
bygroups(Keyword, Text, Keyword, String, Keyword)),
|
|
|
145c2a |
(r'(\s*)(%end)(\s*)', bygroups(Text, Keyword, Text)),
|
|
|
145c2a |
inherit,
|
|
|
145c2a |
diff --git a/pygments/lexers/templates.py b/pygments/lexers/templates.py
|
|
|
145c2a |
index 33c06c4c4..5c3346b4c 100644
|
|
|
145c2a |
--- a/pygments/lexers/templates.py
|
|
|
145c2a |
+++ b/pygments/lexers/templates.py
|
|
|
145c2a |
@@ -1405,7 +1405,7 @@ class EvoqueLexer(RegexLexer):
|
|
|
145c2a |
# see doc for handling first name arg: /directives/evoque/
|
|
|
145c2a |
# + minor inconsistency: the "name" in e.g. $overlay{name=site_base}
|
|
|
145c2a |
# should be using(PythonLexer), not passed out as String
|
|
|
145c2a |
- (r'(\$)(evoque|overlay)(\{(%)?)(\s*[#\w\-"\'.]+[^=,%}]+?)?'
|
|
|
145c2a |
+ (r'(\$)(evoque|overlay)(\{(%)?)(\s*[#\w\-"\'.]+)?'
|
|
|
145c2a |
r'(.*?)((?(4)%)\})',
|
|
|
145c2a |
bygroups(Punctuation, Name.Builtin, Punctuation, None,
|
|
|
145c2a |
String, using(PythonLexer), Punctuation)),
|
|
|
145c2a |
diff --git a/pygments/lexers/varnish.py b/pygments/lexers/varnish.py
|
|
|
145c2a |
index 23653f7a1..9d358bd7c 100644
|
|
|
145c2a |
--- a/pygments/lexers/varnish.py
|
|
|
145c2a |
+++ b/pygments/lexers/varnish.py
|
|
|
145c2a |
@@ -61,7 +61,7 @@ def analyse_text(text):
|
|
|
145c2a |
bygroups(Name.Attribute, Operator, Name.Variable.Global, Punctuation)),
|
|
|
145c2a |
(r'(\.probe)(\s*=\s*)(\{)',
|
|
|
145c2a |
bygroups(Name.Attribute, Operator, Punctuation), 'probe'),
|
|
|
145c2a |
- (r'(\.\w+\b)(\s*=\s*)([^;]*)(\s*;)',
|
|
|
145c2a |
+ (r'(\.\w+\b)(\s*=\s*)([^;\s]*)(\s*;)',
|
|
|
145c2a |
bygroups(Name.Attribute, Operator, using(this), Punctuation)),
|
|
|
145c2a |
(r'\{', Punctuation, '#push'),
|
|
|
145c2a |
(r'\}', Punctuation, '#pop'),
|