Repository navigation
Conversation
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
|
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 Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @movieversalfilm-web. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. 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. |
What?
Closes #79022
Fixes Custom HTML block iframe preview regressions so provider embeds (e.g. Dacast) render in the editor canvas and in the Edit HTML modal without enabling unsafe sandbox combinations.
Why?
After recent sandbox hardening changes, iframe-based embeds in
core/htmlcould fail to render video in editor preview (audio-only or blank preview), and the console could show origin-relatedpostMessageerrors.A previous approach using
allow-scripts+allow-same-originin sandbox is not desirable and triggers browser security warnings.This PR restores editor preview behavior for safe standalone iframe embeds while preserving stricter sandboxing for arbitrary HTML content.
How?
packages/block-library/src/html/preview-utils.jswith guards to detect safe standalone iframe markup:<iframe>srconly (https://,http://, or//)srcdocon*)getSafeStandaloneIframeProps()to extract sanitized iframe attributes for preview rendering.packages/block-library/src/html/preview.js:<iframe>preview for safe standalone iframe markupSandBoxfor all other HTMLpackages/block-library/src/html/edit.js:Previewinline for eligible iframe embeds instead of only showing rawInnerContentpackages/block-library/src/html/editor.scss:packages/block-library/src/html/test/preview-utils.js.Testing Instructions
allow-scripts+allow-same-originis not introduced by this block preview path.Validation run:
npm run lint:js -- packages/block-library/src/html/edit.js packages/block-library/src/html/preview.js packages/block-library/src/html/preview-utils.js packages/block-library/src/html/test/preview-utils.jsnpm run lint:css -- packages/block-library/src/html/editor.scssnpm run test:unit -- packages/block-library/src/html/test/index.js packages/block-library/src/html/test/utils.js packages/block-library/src/html/test/preview-utils.jsTesting Instructions for Keyboard
Tab/arrow keys to move focus through block toolbar and inspector controls.Escor focus + Enter on Cancel) and confirm focus returns predictably to the block controls.Screenshots or screencast
Use of AI Tools
AI assistance was used to help draft and iterate on the implementation and tests.
All generated code and test changes were reviewed, validated, and adjusted before submission.