Skip to content

Commit

Permalink
[ruby/rdoc] Fix polynominal backtracking
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu authored and matzbot committed Apr 29, 2023
1 parent d239643 commit 85a9fd1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rdoc/parser/ruby.rb
Expand Up @@ -2134,7 +2134,7 @@ def read_directive allowed
if :on_nl == tk[:kind] or (:on_kw == tk[:kind] && 'def' == tk[:text]) then
return
elsif :on_comment == tk[:kind] or :on_embdoc == tk[:kind] then
return unless tk[:text] =~ /\s*:?([\w-]+):\s*(.*)/
return unless tk[:text] =~ /:?\b([\w-]+):\s*(.*)/

directive = $1.downcase

Expand Down
7 changes: 7 additions & 0 deletions test/rdoc/test_rdoc_parser_ruby.rb
Expand Up @@ -3350,6 +3350,13 @@ def test_read_directive_one_liner
assert_equal :on_const, parser.get_tk[:kind]
end

def test_read_directive_linear_performance
pre = ->(i) {util_parser '# ' + '0'*i + '=000:'}
assert_linear_performance((1..5).map{|i|10**i}, pre: pre) do |parser|
assert_nil parser.read_directive []
end
end

def test_read_documentation_modifiers
c = RDoc::Context.new

Expand Down

0 comments on commit 85a9fd1

Please sign in to comment.