Markdown.ToHtml throws IndexOutOfRangeException
Metalnem opened this issue · comments
Nemanja Mijailovic commented
The latest version of Markdig can still throw IndexOutOfRangeException from Markdown.ToHtml method (this is different from #276). This time I've collected all the unique stack traces, and minimized the inputs:
IndexOutOfRangeException 1
var pipeline = new MarkdownPipelineBuilder().UseAdvancedExtensions().Build();
Markdown.ToHtml("+-\n|\n+", pipeline);
Exception has occurred: CLR/System.IndexOutOfRangeException
An unhandled exception of type 'System.IndexOutOfRangeException' occurred in Markdig.dll: 'Index was outside the bounds of the array.'
at Markdig.Helpers.StringSlice.TrimStart()
at Markdig.Extensions.Tables.GridTableParser.SetRowSpanState(List`1 columns, StringSlice line, Boolean& isHeaderRow, Boolean& hasRowSpan)
at Markdig.Extensions.Tables.GridTableParser.HandleNewRow(BlockProcessor processor, GridTableState tableState, Table gridTable)
at Markdig.Parsers.BlockProcessor.TryContinueBlocks()
at Markdig.Parsers.BlockProcessor.ProcessLine(StringSlice newLine)
at Markdig.Parsers.MarkdownParser.ProcessBlocks()
at Markdig.Parsers.MarkdownParser.Parse()
at Markdig.Markdown.ToHtml(String markdown, TextWriter writer, MarkdownPipeline pipeline)
at Markdig.Markdown.ToHtml(String markdown, MarkdownPipeline pipeline)
IndexOutOfRangeException 2
var pipeline = new MarkdownPipelineBuilder().UseAdvancedExtensions().Build();
Markdown.ToHtml("+--\n|\n+0", pipeline);
Exception has occurred: CLR/System.IndexOutOfRangeException
An unhandled exception of type 'System.IndexOutOfRangeException' occurred in Markdig.dll: 'Index was outside the bounds of the array.'
at Markdig.Helpers.StringSlice.TrimEnd()
at Markdig.Extensions.Tables.GridTableParser.SetRowSpanState(List`1 columns, StringSlice line, Boolean& isHeaderRow, Boolean& hasRowSpan)
at Markdig.Extensions.Tables.GridTableParser.HandleNewRow(BlockProcessor processor, GridTableState tableState, Table gridTable)
at Markdig.Parsers.BlockProcessor.TryContinueBlocks()
at Markdig.Parsers.BlockProcessor.ProcessLine(StringSlice newLine)
at Markdig.Parsers.MarkdownParser.ProcessBlocks()
at Markdig.Parsers.MarkdownParser.Parse()
at Markdig.Markdown.ToHtml(String markdown, TextWriter writer, MarkdownPipeline pipeline)
at Markdig.Markdown.ToHtml(String markdown, MarkdownPipeline pipeline)
IndexOutOfRangeException 3
var pipeline = new MarkdownPipelineBuilder().UseAdvancedExtensions().Build();
Markdown.ToHtml("+-\n|\n+\n0", pipeline);
Exception has occurred: CLR/System.IndexOutOfRangeException
An unhandled exception of type 'System.IndexOutOfRangeException' occurred in Markdig.dll: 'Index was outside the bounds of the array.'
at Markdig.Extensions.Tables.Table.IsValid()
at Markdig.Extensions.Tables.GridTableParser.TryContinue(BlockProcessor processor, Block block)
at Markdig.Parsers.BlockProcessor.TryContinueBlocks()
at Markdig.Parsers.BlockProcessor.ProcessLine(StringSlice newLine)
at Markdig.Parsers.MarkdownParser.ProcessBlocks()
at Markdig.Parsers.MarkdownParser.Parse()
at Markdig.Markdown.ToHtml(String markdown, TextWriter writer, MarkdownPipeline pipeline)
at Markdig.Markdown.ToHtml(String markdown, MarkdownPipeline pipeline)
IndexOutOfRangeException 4
var pipeline = new MarkdownPipelineBuilder().UseAdvancedExtensions().Build();
Markdown.ToHtml("+-\n|\n+0", pipeline);
Exception has occurred: CLR/System.IndexOutOfRangeException
An unhandled exception of type 'System.IndexOutOfRangeException' occurred in Markdig.dll: 'Index was outside the bounds of the array.'
at Markdig.Extensions.Tables.Table.IsValid()
at Markdig.Extensions.Tables.GridTableParser.Close(BlockProcessor processor, Block block)
at Markdig.Parsers.BlockProcessor.Close(Int32 index)
at Markdig.Parsers.BlockProcessor.CloseAll(Boolean force)
at Markdig.Parsers.MarkdownParser.ProcessBlocks()
at Markdig.Parsers.MarkdownParser.Parse()
at Markdig.Markdown.ToHtml(String markdown, TextWriter writer, MarkdownPipeline pipeline)
at Markdig.Markdown.ToHtml(String markdown, MarkdownPipeline pipeline)
I'm using Markdig 0.15.7 and .NET Core 2.2.103.
Found via SharpFuzz.
Nemanja Mijailovic commented
Yes!