AngleSharp.Css icon indicating copy to clipboard operation
AngleSharp.Css copied to clipboard

background "<bg-position> / <bg-size>" syntax unsupported

Open mganss opened this issue 1 year ago • 1 comments

Prerequisites

  • [X] Can you reproduce the problem in a MWE?
  • [X] Are you running the latest version of AngleSharp.Css?
  • [X] Did you check the FAQs to see if that helps you?
  • [X] Are you reporting to the correct repository? (there are multiple AngleSharp libraries, e.g., AngleSharp.Xml for Xml support)
  • [X] Did you perform a search in the issues?

Description

The syntax for background specifying both position and size separated by a slash is unsupported. #124 seems to be related.

This was initiallly reported as https://github.com/mganss/HtmlSanitizer/issues/536

Steps to Reproduce

var html = @"<div style=""background: center / cover;""></div>";
var conf = Configuration.Default.WithCss(new CssParserOptions
{
    IsIncludingUnknownDeclarations = true,
    IsIncludingUnknownRules = true,
    IsToleratingInvalidSelectors = true,
});
var parser = new HtmlParser(new HtmlParserOptions { IsScripting = true }, BrowsingContext.New(conf));
var dom = parser.ParseDocument(html);
var elem = dom.QuerySelector("div");
var style = elem.GetStyle();
var styleCount = style.Count(); // -> 0

Expected Behavior

The number of styles is nonzero.

Actual Behavior

The number of styles is zero.

Possible Solution / Known Workarounds

No response

mganss avatar Mar 18 '24 15:03 mganss

Getting same problem here, I believe it's because the / is not been skipped by calling SkipSpacesAndComments:

https://github.com/AngleSharp/AngleSharp.Css/blob/459b48c797bf328a611feda56ecece0eb2bd21b7/src/AngleSharp.Css/Declarations/BackgroundDeclaration.cs#L130

Debugger page:

image

ikesnowy avatar Oct 16 '24 13:10 ikesnowy