mirror of
https://github.com/ruby/ruby.git
synced 2025-08-23 13:04:13 +02:00
[ruby/rdoc] Fix polynominal backtracking
Fix https://github.com/ruby/rdoc/pull/995
adfa7db5b9
This commit is contained in:
parent
d239643603
commit
85a9fd1902
2 changed files with 8 additions and 1 deletions
|
@ -2134,7 +2134,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
|
||||||
if :on_nl == tk[:kind] or (:on_kw == tk[:kind] && 'def' == tk[:text]) then
|
if :on_nl == tk[:kind] or (:on_kw == tk[:kind] && 'def' == tk[:text]) then
|
||||||
return
|
return
|
||||||
elsif :on_comment == tk[:kind] or :on_embdoc == tk[:kind] then
|
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
|
directive = $1.downcase
|
||||||
|
|
||||||
|
|
|
@ -3350,6 +3350,13 @@ end
|
||||||
assert_equal :on_const, parser.get_tk[:kind]
|
assert_equal :on_const, parser.get_tk[:kind]
|
||||||
end
|
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
|
def test_read_documentation_modifiers
|
||||||
c = RDoc::Context.new
|
c = RDoc::Context.new
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue