Skip to content

CssText adds replacement character #123

Closed
@mganss

Description

@mganss

I'm not entirely sure if this is a bug but it doesn't seem to occur in browsers. The " is unbalanced in the source so this might trigger the observed behavior.

This was originally reported in mganss/HtmlSanitizer#411

var html = @"<span style=""background-image: var(--urlSpellingErrorV2,url(&quot;https://www.example.com/))"">Ipsum</span>";
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 span = dom.Body.Children[0];
var attr = span.GetAttribute("style"); // -> "background-image: var(--urlSpellingErrorV2,url(\"https://www.example.com/))"
var style = span.GetStyle();
var cssText = style.CssText; // -> "background-image: var(--urlSpellingErrorV2,url(\"https://www.example.com/))\uffff"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions