HtmlDocument.ParseDocumentAsync results in ArgumentOutOfRangeException
See original GitHub issueBug Report
Prerequisites
- Can you reproduce the problem in a MWE?
- Are you running the latest version of AngleSharp?
- Did you check the FAQs to see if that helps you?
- Are you reporting to the correct repository? (there are multiple AngleSharp libraries, e.g.,
AngleSharp.Css
for CSS support) - Did you perform a search in the issues? Yes, #452 But was nothing wrong.
For more information, see the CONTRIBUTING
guide.
Description
Exception when parsing a ‘document’.
System.ArgumentOutOfRangeException
HResult=0x80131502
Message=Index must be within the bounds of the List. (Parameter 'index')
Source=System.Private.CoreLib
StackTrace:
at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
at System.Collections.Generic.List`1.Insert(Int32 index, T item)
at AngleSharp.Html.Parser.HtmlDomBuilder.HeisenbergAlgorithm(HtmlTagToken tag)
at AngleSharp.Html.Parser.HtmlDomBuilder.InBodyEndTag(HtmlTagToken tag)
at AngleSharp.Html.Parser.HtmlDomBuilder.InCell(HtmlToken token)
at AngleSharp.Html.Parser.HtmlDomBuilder.<ParseAsync>d__23.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at AngleSharp.Html.Parser.HtmlParser.<ParseAsync>d__28.MoveNext()
Steps to Reproduce
await new HtmlParser().ParseDocumentAsync(await new HttpClient().GetStringAsync("http://www.artfiles.org/netlib.org/blast/blast-nearterm"));
Expected behavior:
That it handles the input without exception.
Actual behavior:
Something internally goes wrong.
Environment details:
.NET Core 3.1 on Windows 10 Pro 2004
Possible Solution
It looks like it must be something with list management. Hopefully it’s clear and quick to fix.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
HtmlAgilityPack ArgumentOutOfRangeException
Currently, when I run the above, I get an ArgumentOutOfRangeException at string test = doc.DocumentNode.Element("html").Element("body").Element( ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks, ‘verified’! 👍
Fix available in the preview and in
devel
.