Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR hardens Lazy Blocks block-code meta handling against direct WordPress metadata writes.
Root Cause
The block builder REST/UI save path uses
save_meta_boxes(), which checksunfiltered_htmlbefore persisting block code fields. However, XML-RPC/custom fields and other direct metadata API writes can writelazyblocks_code_frontend_htmlwithout going through that save path. A user who can edit Lazy Blocks but does not haveunfiltered_htmlcould therefore persist executable frontend HTML in a block template.This matters for environments such as Multisite site admins, installs with
DISALLOW_UNFILTERED_HTML, or custom roles that haveedit_lazyblockswithoutunfiltered_html.Changes
add_post_metadataandupdate_post_metadataguards for unsafe Lazy Blocks code meta keys.lazyblocks_code_editor_html,lazyblocks_code_frontend_html, andlazyblocks_script_viewunless the current user is allowed unfiltered HTML.add_post_meta()/update_post_meta()calls.Validation
npm run test:unit:php -- --filter test_direct_meta_writes_block_code_fields_for_non_privileged_usersnpm run test:unit:php -- --filter SecurityTestnpm run test:unit:php -- --filter 'SecurityTest|BlockRenderTest|BlockRegistrationTest|ExportPermissionTest'vendor/bin/phpcs --standard=phpcs.xml.dist classes/class-blocks.php tests/phpunit/SecurityTest.php