Skip to content

Tests: Make Block Bindings unsafe HTML test independent of KSES text handling - #14092

Closed
sirreal wants to merge 2 commits into
WordPress:trunkfrom
sirreal:block-bindings-unsafe-html-test
Closed

sirreal wants to merge 2 commits into
WordPress:trunkfrom
sirreal:block-bindings-unsafe-html-test

Conversation

@sirreal

@sirreal sirreal commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Make the Block Bindings unsafe HTML test pass whether KSES keeps or removes the text inside a removed SCRIPT element.

The 'unsafe HTML should be sanitized' case in data_different_get_value_callbacks() compared the rendered paragraph to an exact string. That string depends on how KSES handles the contents of a disallowed SCRIPT element, which changed in r64233 ("KSES: Reimplement with Tag Processor."). The test checks that the SCRIPT element is removed, not what happens to its text.

This moves the case into test_unsafe_html_from_source_is_sanitized(), which renders the bound paragraph and asserts with WP_HTML_Tag_Processor that the output contains no SCRIPT element.

This syncs with Gutenberg PR WordPress/gutenberg#84294, which makes the same change to phpunit/block-bindings-test.php. Gutenberg PR WordPress/gutenberg#84302 applies the same fix to a Gutenberg list item test that has no counterpart in Core.

Trac ticket: https://core.trac.wordpress.org/ticket/66208
Follow-up to r64233.

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Used for: The change was authored with Claude Code and reviewed by the author.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

…handling.

Moves the unsafe HTML case out of `data_different_get_value_callbacks()` into its own test, which asserts that the rendered block contains no SCRIPT element instead of comparing the exact output. The exact output depends on whether KSES keeps or removes the text inside a removed SCRIPT element, which changed in [64233].

See #66208.
sirreal added a commit to WordPress/gutenberg that referenced this pull request Oct 8, 2026
Assert that no SCRIPT element remains instead of comparing the exact
markup, which depends on whether KSES keeps the text of a removed SCRIPT
element.

Core sync: WordPress/wordpress-develop#14092
@sirreal
sirreal marked this pull request as ready for review October 8, 2026 05:32
@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props jonsurrell, mamaduka, andrewserong.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@andrewserong andrewserong left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, too!

@Mamaduka

Copy link
Copy Markdown
Member

I think this just needs to be committed. @sirreal, do you have time to handle this?

wporg-sync pushed a commit that referenced this pull request Oct 15, 2026
Assert that the output has no SCRIPT tag, without depending on how KSES removes it.

Developed in: #14092

Follow-up to r64233.

Props jonsurrell, mamaduka, andrewserong.
See #66208.


git-svn-id: https://develop.svn.wordpress.org/trunk@64355 602fd350-edb4-49c9-b593-d223f7449a82
@sirreal

sirreal commented Oct 15, 2026

Copy link
Copy Markdown
Member Author

Merged in r64355.

@sirreal sirreal closed this Oct 15, 2026
@sirreal
sirreal deleted the block-bindings-unsafe-html-test branch October 15, 2026 08:09
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Oct 15, 2026
Assert that the output has no SCRIPT tag, without depending on how KSES removes it.

Developed in: WordPress/wordpress-develop#14092

Follow-up to r64233.

Props jonsurrell, mamaduka, andrewserong.
See #66208.

Built from https://develop.svn.wordpress.org/trunk@64355


git-svn-id: http://core.svn.wordpress.org/trunk@63505 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants