Ticket #15 (assigned defect)
Long lists cause stack overflow
| Reported by: | John Croisant <jacius@…> | Owned by: | deveiant |
|---|---|---|---|
| Priority: | high | Milestone: | Bugfixes |
| Component: | API | Version: | 1.0.0 |
| Severity: | major | Keywords: | regexp overflow bug |
| Cc: |
Description
BlueCloth breaks with a stack overflow if it tries to parse a list (either ordered or unordered) that is too long:
RegexpError: Stack overflow in regexp matcher: /
^ # Start of line
<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script) # Start tag: \2
\b # word break
(.*\n)*? # Any number of lines, minimal match
<\/\1> # Matching end tag
[ ]* # trailing spaces
(?=\n+|\Z) # End of line or document
/ix
from ./bluecloth.rb:342:in `gsub!'
from ./bluecloth.rb:342:in `hide_html_blocks'
from ./bluecloth.rb:248:in `apply_block_transforms'
from ./bluecloth.rb:202:in `to_html'
The number of list items it can handle is inversely related to how long the list items are. With 26-character lines (eg. 'a'..'z'), BlueCloth will break on 78 items or above.
I've attached a little script to hopefully help test this. You can vary the item length and test a range to see how many list items BlueCloth can handle.
This might be a bug in ruby itself, in which case I request that you pass it upstream. Even then, there might be a way that BlueCloth could get around it.
I originally noticed this while maintaining a wiki running on Instiki 0.9.1 (http://www.instiki.org). The version string for the BlueCloth source used by Instiki is:
# $Id: bluecloth.rb,v 1.3 2004/05/02 15:56:33 webster132 Exp $
