Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CssText adds replacement character #123

Closed
mganss opened this issue Dec 13, 2022 · 2 comments
Closed

CssText adds replacement character #123

mganss opened this issue Dec 13, 2022 · 2 comments
Labels
Milestone

Comments

@mganss
Copy link
Contributor

mganss commented Dec 13, 2022

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"
@FlorianRappl
Copy link
Contributor

Yes definitely a bug. I'll try to find some time to look into it!

Thanks for reporting.

@FlorianRappl FlorianRappl added this to the v1.0 milestone Jan 15, 2023
@FlorianRappl
Copy link
Contributor

Implemented. Part of next preview and the 1.0.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants