Skip to content

Commit

Permalink
Fix backtracking Modula2 string regexes.
Browse files Browse the repository at this point in the history
  • Loading branch information
birkenfeld committed Dec 24, 2020
1 parent f65ac3f commit 218f63a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
5 changes: 4 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ Version 2.7.4
(not released yet)

- Fixed infinite loop in SML lexer (#1625)
- Fixed backtracking string regexes in JavaScript/TypeScript lexers (#1637)
- Fixed backtracking string regexes in JavaScript/TypeScript and Modula2
lexers (#1637)
- Limit recursion with nesting Ruby heredocs (#1638)
- Fixed a few inefficient regexes for guessing lexers
- Fixed the raw token lexer handling of Unicode (#1616)

Thanks to Google's OSS-Fuzz project for finding many of these bugs.


Version 2.7.3
-------------
Expand Down
14 changes: 12 additions & 2 deletions pygments/lexers/modula2.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,18 @@ class Modula2Lexer(RegexLexer):
(r'[0-9A-F]+H', Number.Hex),
],
'string_literals': [
(r"'(\\\\|\\'|[^'])*'", String), # single quoted string
(r'"(\\\\|\\"|[^"])*"', String), # double quoted string
(r"'", String, 'string-single'),
(r'"', String, 'string-double'),
],
'string-double': [
(r'\\.', String),
(r'[^\\"]+', String),
(r'"', String, '#pop'),
],
'string-single': [
(r'\\.', String),
(r"[^\\']+", String),
(r"'", String, '#pop'),
],
'digraph_operators': [
# Dot Product Operator
Expand Down

0 comments on commit 218f63a

Please sign in to comment.