summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKornelius Kalnbach <murphy@rubychan.de>2015-03-21 03:44:49 +0100
committerKornelius Kalnbach <murphy@rubychan.de>2015-03-21 03:44:49 +0100
commite5624a07e95cc7a3c704a4d08cddea582adc7f31 (patch)
tree0cc9081e8ef67be734bf6aa3e13230ef66ae8c59 /lib
parent31a09b7599fb7c4b605869127e38617ce7619106 (diff)
downloadcoderay-e5624a07e95cc7a3c704a4d08cddea582adc7f31.tar.gz
prevent running out of regexp stack
Diffstat (limited to 'lib')
-rw-r--r--lib/coderay/scanners/diff.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/coderay/scanners/diff.rb b/lib/coderay/scanners/diff.rb
index fd1aed6..74a6c27 100644
--- a/lib/coderay/scanners/diff.rb
+++ b/lib/coderay/scanners/diff.rb
@@ -100,7 +100,7 @@ module Scanners
next
elsif match = scan(/-/)
deleted_lines_count += 1
- if options[:inline_diff] && deleted_lines_count == 1 && (changed_lines_count = 1 + check(/.*(?:\n\-.*)*/).count("\n")) && match?(/(?>.*(?:\n\-.*){#{changed_lines_count - 1}}(?:\n\+.*){#{changed_lines_count}})$(?!\n\+)/)
+ if options[:inline_diff] && deleted_lines_count == 1 && (changed_lines_count = 1 + check(/.*(?:\n\-.*)*/).count("\n")) && changed_lines_count <= 100_000 && match?(/(?>.*(?:\n\-.*){#{changed_lines_count - 1}}(?:\n\+.*){#{changed_lines_count}})$(?!\n\+)/)
deleted_lines = Array.new(changed_lines_count) { |i| skip(/\n\-/) if i > 0; scan(/.*/) }
inserted_lines = Array.new(changed_lines_count) { |i| skip(/\n\+/) ; scan(/.*/) }