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

Projects
None yet
2 participants
@westonruter
Copy link
Member

westonruter commented Mar 8, 2018

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 Mar 8, 2018

@coreymckrill
Copy link
Contributor

coreymckrill left a comment

Looks good to me.

@westonruter westonruter merged commit 8079fcd into develop Mar 9, 2018

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@westonruter westonruter deleted the fix/style-attribute-processing branch Mar 9, 2018

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