rdoc icon indicating copy to clipboard operation
rdoc copied to clipboard

RDoc::Markdown.parse crashes with invalid inline note

Open zelivans opened this issue 7 years ago • 0 comments

This bug is similar to https://github.com/ruby/rdoc/issues/654, but the context is different and the bug itself is in another method.

Raw crash

/shared/rdoc/lib/rdoc/markdown.rb:15451:in `_InlineNote': undefined method `length' for nil:NilClass (NoMethodError)
	from /shared/rdoc/lib/rdoc/markdown.rb:481:in `apply'
	from /shared/rdoc/lib/rdoc/markdown.rb:9521:in `_Inline'
	from /shared/rdoc/lib/rdoc/markdown.rb:481:in `apply'
	from /shared/rdoc/lib/rdoc/markdown.rb:11888:in `_Label'
	from /shared/rdoc/lib/rdoc/markdown.rb:481:in `apply'
	from /shared/rdoc/lib/rdoc/markdown.rb:11750:in `_Reference'
	from /shared/rdoc/lib/rdoc/markdown.rb:481:in `apply'
	from /shared/rdoc/lib/rdoc/markdown.rb:12275:in `_References'
	from /shared/rdoc/lib/rdoc/markdown.rb:481:in `apply'
	from /shared/rdoc/lib/rdoc/markdown.rb:388:in `parse'
	from /shared/rdoc/lib/rdoc/markdown.rb:777:in `parse'
	from /shared/rdoc/lib/rdoc/markdown.rb:621:in `parse'
	from tst.rb:10:in `<main>'

Example input

[`^[0]

Explanation

It seems the _InlineNote method is called before note_order is initialized, and _InlineNote does not expect it to be nil, calling length on it without checking its value, resulting in a unhandled NoMethodError.

zelivans avatar Sep 22 '18 12:09 zelivans