Color not parsed correctly if rgb is not all lowercase
mganss opened this issue · comments
var html = @"<p style='color: RGB(0,17,0)'>Text</p>";
var parser = new HtmlParser(new HtmlParserOptions(), BrowsingContext.New(Configuration.Default.WithCss(new CssParserOptions())));
var dom = parser.ParseDocument(html);
var p = dom.QuerySelector("p");
var s = p.GetStyle();
var color = s.GetColor(); // -> ""
Perhaps this occurs because the dictionary here does not use a comparer that ignores case:
AngleSharp.Css/src/AngleSharp.Css/Parser/Micro/ColorParser.cs
Lines 11 to 20 in 248a870
This was originally reported as mganss/HtmlSanitizer#340.
It's a good point. Right now everything is case sensitive, but actually function names (and color names) should be case insensitive:
See https://www.w3.org/TR/css-color-4/#resolving-sRGB-values.
Isn't it the other way around, i.e. it should be case insensitive (rgb
and RgB
are treated the same, case is ignored) and currently it's case sensitive (only lowercase works)?
Isn't it the other way around, i.e. it should be case insensitive (rgb and RgB are treated the same, case is ignored) and currently it's case sensitive (only lowercase works)?
Correct(ed) - that's what I meant.
Landed in devel
.