Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown.ToHtml throws IndexOutOfRangeException #303

Closed
Metalnem opened this issue Feb 5, 2019 · 2 comments
Closed

Markdown.ToHtml throws IndexOutOfRangeException #303

Metalnem opened this issue Feb 5, 2019 · 2 comments

Comments

@Metalnem
Copy link

Metalnem commented Feb 5, 2019

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.

webmaster442 added a commit to webmaster442/markdig that referenced this issue Mar 3, 2020
xoofx added a commit that referenced this issue Mar 8, 2020
@rstm-sf
Copy link

rstm-sf commented Nov 17, 2022

Fixed by #404?

@Metalnem
Copy link
Author

Metalnem commented Jun 9, 2023

Yes!

@Metalnem Metalnem closed this as completed Jun 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants