Skip to content

Commit

Permalink
JavaLexer: Fix a catastrophic backtracking bug
Browse files Browse the repository at this point in the history
  • Loading branch information
kurtmckee committed Nov 9, 2020
1 parent d06e8a4 commit 8a505c8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pygments/lexers/jvm.py
Expand Up @@ -65,7 +65,7 @@ class JavaLexer(RegexLexer):
'var'),
(r'(import(?:\s+static)?)(\s+)', bygroups(Keyword.Namespace, Text),
'import'),
(r'"(\\\\|\\"|[^"])*"', String),
(r'"', String, 'string'),
(r"'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'", String.Char),
(r'(\.)((?:[^\W\d]|\$)[\w$]*)', bygroups(Punctuation,
Name.Attribute)),
Expand Down Expand Up @@ -96,6 +96,13 @@ class JavaLexer(RegexLexer):
'import': [
(r'[\w.]+\*?', Name.Namespace, '#pop')
],
'string': [
(r'[^\\"]+', String),
(r'\\\\', String), # Escaped backslash
(r'\\"', String), # Escaped quote
(r'\\', String), # Bare backslash
(r'"', String, '#pop'), # Closing quote
],
}


Expand Down

0 comments on commit 8a505c8

Please sign in to comment.