Skip to content

Commit adfa7db

Browse files
committed
Fix polynominal backtracking
Fix #995
1 parent 8ff1604 commit adfa7db

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/rdoc/parser/ruby.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2134,7 +2134,7 @@ def read_directive allowed
21342134
if :on_nl == tk[:kind] or (:on_kw == tk[:kind] && 'def' == tk[:text]) then
21352135
return
21362136
elsif :on_comment == tk[:kind] or :on_embdoc == tk[:kind] then
2137-
return unless tk[:text] =~ /\s*:?([\w-]+):\s*(.*)/
2137+
return unless tk[:text] =~ /:?\b([\w-]+):\s*(.*)/
21382138

21392139
directive = $1.downcase
21402140

test/rdoc/test_rdoc_parser_ruby.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3350,6 +3350,13 @@ def test_read_directive_one_liner
33503350
assert_equal :on_const, parser.get_tk[:kind]
33513351
end
33523352

3353+
def test_read_directive_linear_performance
3354+
pre = ->(i) {util_parser '# ' + '0'*i + '=000:'}
3355+
assert_linear_performance((1..5).map{|i|10**i}, pre: pre) do |parser|
3356+
assert_nil parser.read_directive []
3357+
end
3358+
end
3359+
33533360
def test_read_documentation_modifiers
33543361
c = RDoc::Context.new
33553362

0 commit comments

Comments
 (0)