Skip to content

Very long data URIs disappear from @font-face declaration #76

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

Closed
mganss opened this issue Aug 6, 2021 · 2 comments
Closed

Very long data URIs disappear from @font-face declaration #76

mganss opened this issue Aug 6, 2021 · 2 comments

Comments

@mganss
Copy link
Contributor

mganss commented Aug 6, 2021

Example code:

var url = "..."; // data: url with length >= 24294 
var html = $@"<style>@font-face {{
font-family: ""MyFont"";
src: url(""{url}"") format('woff');
font-weight: normal;
font-style: normal;
font-display: swap;
}}</style>";

var parser = new HtmlParser(new HtmlParserOptions(), BrowsingContext.New(Configuration.Default.WithCss(new CssParserOptions
{
    IsIncludingUnknownDeclarations = true,
    IsIncludingUnknownRules = true,
    IsToleratingInvalidSelectors = true,
})));
var dom = parser.ParseDocument(html);
var css = ((ICssStyleSheet)dom.StyleSheets[0]).Rules[0].CssText;
// -> @font-face { font-family: "MyFont"; src: ; font-weight: normal; font-style: normal }

This seems to be the root cause of the issue reported in mganss/HtmlSanitizer#66 (comment)

@FlorianRappl
Copy link
Contributor

Thanks for the report. I'll look into it!

@FlorianRappl
Copy link
Contributor

Available in devel and the 0.16.1 (prerelease / release later).

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

No branches or pull requests

2 participants