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

Eliminate use of safecss_filter_attr() in processing style attributes since redundant and lossy #1004

Merged
merged 1 commit into from
Mar 9, 2018

Conversation

westonruter
Copy link
Member

Fixes #613.

There is a problem with the use of safecss_filter_attr() in \AMP_Style_Sanitizer::process_style() introduced via https://github.com/Automattic/amp-wp/blob/23eced628815e169ca9831b2ccb460b49adc53c1/includes/sanitizers/class-amp-style-sanitizer.php#L456

This is what is removing the display property. It was introduced in de2a303 with the comment:

Filter the styles using safecss_filter_attr() to make sure there
aren't any funky properties. Also alphabetize the valid properties so
that variable order doesn't cause unnecessary duplication.

The logic in safecss_filter_attr() is already being run on post save to strip out display, if the user doesn't have unfiltered_html. So this is preventing safecss_filter_attr() from being called a second time when displaying the post, resulting in a plugin that outputs a Kses-illegal style property to be also erroneously stripped. Otherwise, if a user does have unfiltered_html then they currently aren't able to do so in AMP even in spite of the sanitizer.

@westonruter westonruter added this to the v0.7 milestone Mar 8, 2018
@westonruter westonruter requested a review from coreymckrill March 8, 2018 22:31
Copy link
Contributor

@coreymckrill coreymckrill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@westonruter westonruter merged commit 8079fcd into develop Mar 9, 2018
@westonruter westonruter deleted the fix/style-attribute-processing branch March 9, 2018 18:14
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

Successfully merging this pull request may close these issues.

2 participants