AngleSharp / AngleSharp

:angel: The ultimate angle brackets parser library parsing HTML5, MathML, SVG and CSS to construct a DOM based on the official W3C specifications.

Home Page:https://anglesharp.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

InvalidOperationException: Stack empty in AngleSharp.Html.Parser.HtmlDomBuilder

mschessler opened this issue · comments

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?

Description

System.InvalidOperationException: Stack empty.
at System.Collections.Generic.Stack1.ThrowForEmptyStack() at System.Collections.Generic.Stack1.Pop()
at AngleSharp.Html.Parser.HtmlDomBuilder2.CloseTemplateMode() at AngleSharp.Html.Parser.HtmlDomBuilder2.CloseTemplate()
at AngleSharp.Html.Parser.HtmlDomBuilder2.InHead(StructHtmlToken& token) at AngleSharp.Html.Parser.HtmlDomBuilder2.InBodyEndTag(StructHtmlToken& tag)
at AngleSharp.Html.Parser.HtmlDomBuilder2.InBody(StructHtmlToken& token) at AngleSharp.Html.Parser.HtmlDomBuilder2.Home(StructHtmlToken& token)
at AngleSharp.Html.Parser.HtmlDomBuilder2.Consume(StructHtmlToken& token) at AngleSharp.Html.Parser.HtmlDomBuilder2.Parse(HtmlParserOptions options, TokenizerMiddleware middleware)
at AngleSharp.Html.Parser.HtmlParser.Parse(HtmlDocument document, String stopAt)
at AngleSharp.Html.Parser.HtmlParser.ParseDocument(Char[] source, Int32 length)

Steps to Reproduce

var html = "<svg><template><title><v></temPlate>";
var parser = new AngleSharp.Html.Parser.HtmlParser();
parser.ParseDocument(html.ToCharArray(), 0);

Expected Behavior

Don't crash

Actual Behavior

Crash

Possible Solution / Known Workarounds

No response

Thanks! Fixed in latest preview.