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

Html sanitize css property background-repeat #243

Closed
lukapor opened this issue Oct 20, 2020 · 3 comments
Closed

Html sanitize css property background-repeat #243

lukapor opened this issue Oct 20, 2020 · 3 comments

Comments

@lukapor
Copy link

lukapor commented Oct 20, 2020

Attached file sample htmlBackgroundNoRepeat.html has css property background-repeat. When I sanitize html, property is gone and sanitize html is broken (cleanHtmlBackgroundNoRepeat.html).
attachedFiles.zip

@mganss
Copy link
Owner

mganss commented Oct 20, 2020

Here's the original HTML (please post such short snippets directly in the issue comments):

<div style="font-size: 12pt; font-family: 'Segoe UI';">
    <div fr-original-style="width: 400px; height: 400px; background-image: url('https://user-images.githubusercontent.com/42636057/96471112-437d9a80-122f-11eb-86c2-f30d9b0c8054.png'); background-repeat: no-repeat;"
        style="width: 400px; height: 400px; background-image: url('https://user-images.githubusercontent.com/42636057/96471112-437d9a80-122f-11eb-86c2-f30d9b0c8054.png'); background-repeat: no-repeat;">
        test</div>
</div>

This is a bug that occurs because the parser unravels shorthand CSS properties such as background-repeat to their longhand representations such as background-repeat-x and background-repeat-y. I'll add the missing longhand values to the default configuration. In the meantime, you can add the missing values yourself by doing

sanitizer.AllowedCssProperties.Add("background-repeat-x");
sanitizer.AllowedCssProperties.Add("background-repeat-y");

Do you mean this by broken or do you think there is an additional issue? It seems that in the attached output file the newlines are missing but I can't repro that.

@mganss
Copy link
Owner

mganss commented Oct 20, 2020

While the above is true as a cause for the issue it seems there aren't officially CSS properties background-repeat-x and background-repeat-y. Investigating.

@mganss
Copy link
Owner

mganss commented Oct 20, 2020

Chromium implements this partially (you can still see it in dev tools) and there were discussions to add it to the specification but it was decided against AFAICT: w3c/csswg-drafts#116
I'll add the longhands nonetheless to solve this issue.

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

No branches or pull requests

2 participants