AngleSharp / AngleSharp.Css

:angel: Library to enable support for cascading stylesheets in AngleSharp.

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NullReferenceException in `ToCss()`

mganss opened this issue · comments

var html = "<div style=\"border-width:1px;border-right-width:px;\"></div>";
var parser = new HtmlParser(new HtmlParserOptions(), BrowsingContext.New(Configuration.Default.WithCss(new CssParserOptions())));
var dom = parser.ParseDocument(html);
var div = dom.Body?.FirstElementChild;
var style = div.GetStyle();
var css = style.ToCss(); // -> exception

AngleSharp.Css version is 0.17.0.

The combination of property values has to be very specific to trigger the issue. This does not occur if only border-right-width:px is given or border-right-width:1px;border-right-width:px.

This was initially reported as mganss/HtmlSanitizer#426.