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

CSS (shorthand) properties getting removed #178

Closed
Epicycle23 opened this issue Jul 22, 2019 · 5 comments
Closed

CSS (shorthand) properties getting removed #178

Epicycle23 opened this issue Jul 22, 2019 · 5 comments

Comments

@Epicycle23
Copy link

Epicycle23 commented Jul 22, 2019

Hello,

just stumbled over this, not sure if it's a known issue/wanted behaviour but when sanitizing the following fragment with default settings the style tag gets removed completely:

new HtmlSanitizer().Sanitize("<p><span style=\"text-decoration: underline;\">bla</span></p>");

When iterating the styles it checks for text-decoration-style, text-decoration-color and text-decoration-line instead of text-decoration (the actual CssText) which is included in AllowedCssProperties while the former ones are not.

Found on current master and 5.0.218-beta package.
My apologies if this is intended I just find it odd because the text-decoration property is included in the default allowed css properties.

@mganss
Copy link
Owner

mganss commented Jul 22, 2019

AngleSharp.Css expands shorthand properties into longhands since 0.10 (see AngleSharp/AngleSharp.Css#9).

I guess we'll have to add all the longhand property names to the default list of allowed properties.

@mganss mganss closed this as completed in e114c6f Jul 22, 2019
@mganss
Copy link
Owner

mganss commented Jul 22, 2019

I've added the longhands for which we had shorthands already in the configuration and will update docs accordingly.

@om-ha
Copy link

om-ha commented Dec 28, 2019

Happy holidays @mganss

Could you please push the latest version (v5.0.287) to NuGet?
Release Tag
Commit

It has this issue's fix that I want.

A bunch of my style tags are gone when sanitizing 😶rendering the output HTML undesirable.
I want to try the solution addressed in this issue. But I can't because it's not on NuGet.

If you can't push to NuGet, do you recommend any other alternatives? Should I build HtmlSanitizer myself and including it as a DLL?

@mganss
Copy link
Owner

mganss commented Dec 28, 2019

Happy holidays @om-ha This is included in 5.0.274-beta.

@om-ha
Copy link

om-ha commented Dec 29, 2019

@mganss Thanks! I see.. then my problem still persists even with this fix.

My issue has a different root cause. Created a new one here with the solution and closed it.

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

3 participants