Bugs: Browse | Submit New | Admin

[#29301] StringScanner::Error: regexp buffer overflow on large codeblocks

Date:
2011-06-30 17:50
Priority:
3
Submitted By:
Vinod Kurup (vkurup)
Assigned To:
Thomas Leitner (gettalong)
Category:
Parser
State:
Closed
Summary:
StringScanner::Error: regexp buffer overflow on large codeblocks

Detailed description
I think this is similar to bug #28917, but in codeblocks. I'm using Kramdown 0.13.3. Seems to break with blocks longer
than about 70 lines. (I know, I know, what am I doing with code blocks that long on my blog?)

Test case:

irb> codesnip = "75 character line of code" * 3
irb> codeline = "    " + codesnip + "\n"
irb> codeblock = codeline * 100
irb> Kramdown::Document.new(codeblock).to_html

Results in this error:

StringScanner::Error: regexp buffer overflow
	from /usr/lib/ruby/gems/1.8/gems/kramdown-0.13.3/lib/kramdown/parser/kramdown/codeblock.rb:37:in `scan'
	from /usr/lib/ruby/gems/1.8/gems/kramdown-0.13.3/lib/kramdown/parser/kramdown/codeblock.rb:37:in `parse_codeblock'
	from /usr/lib/ruby/gems/1.8/gems/kramdown-0.13.3/lib/kramdown/parser/kramdown.rb:140:in `send'
	from /usr/lib/ruby/gems/1.8/gems/kramdown-0.13.3/lib/kramdown/parser/kramdown.rb:140:in `parse_blocks'
	from /usr/lib/ruby/gems/1.8/gems/kramdown-0.13.3/lib/kramdown/options.rb:367:in `any?'
	from /usr/lib/ruby/gems/1.8/gems/kramdown-0.13.3/lib/kramdown/parser/kramdown.rb:138:in `each'
	from /usr/lib/ruby/gems/1.8/gems/kramdown-0.13.3/lib/kramdown/parser/kramdown.rb:138:in `any?'
	from /usr/lib/ruby/gems/1.8/gems/kramdown-0.13.3/lib/kramdown/parser/kramdown.rb:138:in `parse_blocks'
	from /usr/lib/ruby/gems/1.8/gems/kramdown-0.13.3/lib/kramdown/parser/kramdown.rb:135:in `catch'
	from /usr/lib/ruby/gems/1.8/gems/kramdown-0.13.3/lib/kramdown/parser/kramdown.rb:135:in `parse_blocks'
	from /usr/lib/ruby/gems/1.8/gems/kramdown-0.13.3/lib/kramdown/parser/kramdown.rb:101:in `parse'
	from /usr/lib/ruby/gems/1.8/gems/kramdown-0.13.3/lib/kramdown/parser/base.rb:78:in `parse'
	from /usr/lib/ruby/gems/1.8/gems/kramdown-0.13.3/lib/kramdown/document.rb:89:in `initialize'
	from (irb):56:in `new'
	from (irb):56
	from :0

Add A Comment: Notepad

Please login


Followup

Message
Date: 2013-05-09 06:56
Sender: Thomas Leitner

This should be fixed in version 1.0.2 - please let me know if
you are still running into problems! Thanks!
Date: 2013-04-26 10:01
Sender: Kyle Barbour

Understood, thank you for the clarification!

I'm not a coder, but if there's anything I can do to help you
out, please let me know. I'm running into this situation with
long footnotes, but after running through some test cases I discovered
that it's not any long footnote, but I'm not sure what triggers
it. Trying to test further although perhaps you already know
what the problem is and don't need any further insights.
Date: 2013-04-26 06:39
Sender: Thomas Leitner

See Github Issue 45 https://github.com/gettalong/kramdown/issues/
45

Originally this bug only affected Ruby 1.8 but there seem to
be cases where the new regexp engine in Ruby 1.9 and 2.0 are
also affected. So this will be fixed.
Date: 2013-04-26 00:41
Sender: Kyle Barbour

Hello there,

I'm having a similar error, although with footnotes, not codeblocks,
and I'm using Ruby 1.9.2p0 and kramdown 1.0.1. Are you saying
that this is solved if I upgrade to Ruby 2.0? Or that you won't
be fixing this at all? Can you clarify?

It would be great if there is some solution to this issue, either
in a future release or by upgrading my Ruby version, since the
restrictions that this places are unfortunate and probably not
desired.
Date: 2013-03-10 11:14
Sender: Thomas Leitner

Since Ruby 1.8 is going the way of the Dodo and Ruby 2.0 is finally
here, I won't be fixing this one. Patches are welcome.
Date: 2011-09-24 12:48
Sender: Thomas Leitner

Thanks for reporting, will have a look at it!

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

Field Old Value Date By
close_date2013-05-09 06:562013-05-09 06:56gettalong
close_date2013-04-26 06:392013-04-26 06:39gettalong
close_date2013-03-10 11:142013-03-10 11:14gettalong
resolution_idNone2013-03-10 11:14gettalong
status_idOpen2013-03-10 11:14gettalong