-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Section Styles: Fix insecure properties removal for inner block types and elements #66896
Section Styles: Fix insecure properties removal for inner block types and elements #66896
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
@BogdanUngureanu if you have some time to test this one and make sure it is actually fixing the issue for you, that would be awesome, cheers 🙏 |
This bug fix might be a candidate for a 6.7.1 point release. In the meantime, I'll get the backport sorted later today. |
35dcba4
to
0f006ca
Compare
Flaky tests detected in 0f006ca. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/11772082349
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great description @aaronrobertshaw, thanks for all the extra context here! This is testing nicely for me:
✅ Confirmed the issue on trunk
with my local environment updated to allow color-mix
and with the admin user without the unfiltered_html
capability
✅ Confirmed that with this PR applied, the section styles are output correctly
✅ The added functions improve readability while also allowing for re-use of the elements logic
Also, I like the comments in the tests that make it clear which bits shouldn't appear in the results 👍
Trunk (missing section styles) | This PR |
---|---|
LGTM! 🚀
Works like a charm for me too, thanks! |
For some reason I opted to test this locally with a custom theme. Anyway, here's what I eventually did:
|
… and elements (WordPress#66896) Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org> Co-authored-by: andrewserong <andrewserong@git.wordpress.org> Co-authored-by: BogdanUngureanu <bogdanungureanu@git.wordpress.org> Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Fixes: #66799
What?
Fixes an issue where block style variations containing inner block type and element styles would have those inner styles stripped when the user attempting to save Global Styles does not have the
unfiltered_html
capability.Why?
The bug prevents proper saving of Global Styles with block style variations containing inner block/element styles when on multisite setups. This leads to unexpected styling when switching style variations etc.
How?
Extends the
remove_insecure_properties
function to process the inner block type styles for variations including their nested element styles.Testing Instructions
Setup
To test this fix, we need a theme that defines block style variations with inner block type styles. The easiest approach is to use an existing theme that has already done all that config. The catch with the below theme is that it uses
color-mix
styles that needs to be added to the allowed safe css atts (this is being handled separately).unfiltered_html
caps but can access the site editor. See linked issue for options.Block markup with section style applied
kses.php
in your local WP instance to allowcolor-mix
style values.Steps
Easy
npm run test:unit:php:base -- --filter WP_Theme_JSON_Gutenberg_Test
Manual
On trunk:
unfiltered_html
caps and visit the site editorThis PR:
Reset global styles
Repeat the steps for trunk
Note that the separator's styles on the frontend now include the correct section style
Bonus points: If the unit tests aren't enough; add some debugging to log the variation input/output in
remove_insecure_properties
and validate the expected output is shown in error logs when attempting to save Global Styles.Quick and dirty debug log diff
Screenshots or screencast