diff options
author | Georg Brandl <georg@python.org> | 2020-12-17 08:03:20 +0100 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2020-12-17 08:03:20 +0100 |
commit | a56ed8a1f2eb0db14aad50cb7e4eaaf7f2f0d3b3 (patch) | |
tree | ea548a3807caee51edceec97e9bb301117fc3882 /pygments/lexers/ruby.py | |
parent | 7958cd6c53215ac2caeb6812aaeab5e8029a43ad (diff) | |
download | pygments-git-a56ed8a1f2eb0db14aad50cb7e4eaaf7f2f0d3b3.tar.gz |
Limit recursion with nesting Ruby heredocs
fixes #1638
Diffstat (limited to 'pygments/lexers/ruby.py')
-rw-r--r-- | pygments/lexers/ruby.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/pygments/lexers/ruby.py b/pygments/lexers/ruby.py index e16cd711..d1ae5aff 100644 --- a/pygments/lexers/ruby.py +++ b/pygments/lexers/ruby.py @@ -57,8 +57,11 @@ class RubyLexer(ExtendedRegexLexer): ctx.pos = match.start(5) ctx.end = match.end(5) - # this may find other heredocs - yield from self.get_tokens_unprocessed(context=ctx) + # this may find other heredocs, so limit the recursion depth + if len(heredocstack) < 100: + yield from self.get_tokens_unprocessed(context=ctx) + else: + yield ctx.pos, String.Heredoc, match.group(5) ctx.pos = match.end() if outermost: |