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

Update style sanitizer approach #935

Merged
merged 7 commits into from Feb 7, 2018

Conversation

Projects
None yet
3 participants
@westonruter
Copy link
Member

commented Feb 6, 2018

  • Eliminate custom WP_Styles in favor of consolidating logic in AMP_Style_Sanitizer. This ensures that plugins that print link tags directly will automatically get them included. The same goes for style elements that a plugin prints.
  • External stylesheets and style elements now get concatenated in document order to ensure proper cascade.
  • Include CSS comment before each concatenated stylesheet indicating its source. This helps with debugging.
  • Run !important and overflow removal logic on inlined external stylesheets as well as style elements and style attributes.
  • Make sure that !important does not appear anywhere in CSS, including comments, as otherwise invalid and entire CSS gets stripped by whitelist sanitizer.
  • Stop concatenating CSS stylesheets to output if surpasses max size; show HTML comment containing the stylesheet URL that was excluded due to size. This helps with debugging.
  • Enforce that style sanitizer and whitelist sanitizer always run last.

Fixes #927. However, the longer-term fixes will need to be done as part of #930. This PR lays the groundwork for #930.

@westonruter westonruter requested a review from ThierryA Feb 6, 2018

@westonruter westonruter added this to the v0.7 milestone Feb 6, 2018

@ThierryA
Copy link
Collaborator

left a comment

Awesome improvements!

$guessurl = site_url();
if ( ! $guessurl ) {
$guessurl = wp_guess_url();

This comment has been minimized.

Copy link
@ThierryA

ThierryA Feb 6, 2018

Collaborator

I did not know that function, nice!

Travis Failed

@amedina

This comment has been minimized.

Copy link
Member

commented Feb 6, 2018

@weston are we avoiding this: "Run !important removal logic" as discussed with @pbakaus?

@westonruter

This comment has been minimized.

Copy link
Member Author

commented Feb 6, 2018

@amedina Not yet. That will be addressed as part of #930. We can't do it yet because we don't have a CSS parser.

(I'll be squashing the commits once I identify why Travis is failing.)

@westonruter westonruter force-pushed the update/style-sanitizer-approach branch 11 times, most recently from 2ea228c to 7452b00 Feb 6, 2018

@westonruter westonruter force-pushed the update/style-sanitizer-approach branch from 7452b00 to 4f61eef Feb 7, 2018

@westonruter

This comment has been minimized.

Copy link
Member Author

commented Feb 7, 2018

Wow, that was one of the most obscure things I've ever had to debug.

@westonruter westonruter merged commit 215860d into develop Feb 7, 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 update/style-sanitizer-approach branch Feb 7, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.