From 513f8fc34f7ec915994ac226ff333b2f6864b54c Mon Sep 17 00:00:00 2001 From: Jean Abou-Samra Date: Thu, 15 Sep 2022 15:02:04 +0200 Subject: Objective-J: fix catastrophic backtracking in comment regex (#2225) This use of *? was both incorrect and catastrophically backtracking when embedding this regex into a larger regex with a trailing pattern, since it could match much more than intended and try exponentially many positions in that process. --- pygments/lexers/javascript.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pygments/lexers/javascript.py') diff --git a/pygments/lexers/javascript.py b/pygments/lexers/javascript.py index 1896fb46..864a9043 100644 --- a/pygments/lexers/javascript.py +++ b/pygments/lexers/javascript.py @@ -801,7 +801,7 @@ class ObjectiveJLexer(RegexLexer): mimetypes = ['text/x-objective-j'] #: optional Comment or Whitespace - _ws = r'(?:\s|//.*?\n|/[*].*?[*]/)*' + _ws = r'(?:\s|//[^\n]*\n|/[*](?:[^*]|[*][^/])*[*]/)*' flags = re.DOTALL | re.MULTILINE -- cgit v1.2.1