Skip to content

Conversation

@westonruter
Copy link
Member

@westonruter westonruter commented Feb 3, 2026

This further improves back-compat for wp.sanitize.stripTags() when a falsy value is passed, including false, 0, and NaN. In these three cases, the function in 6.9 returns an empty string. In contrast, the function in 7.0-alpha would return stringifed versions of those falsy valies.

Follow-up to:

Trac ticket: https://core.trac.wordpress.org/ticket/64574


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.

westonruter and others added 2 commits February 3, 2026 11:03
Co-authored-by: Jon Surrell <jonsurrell@git.wordpress.org>
Adds QUnit tests for `wp.sanitize.stripTags()` with inputs `0` (number), `'0'` (string), and `''` (empty string) to ensure they are handled correctly and not treated as null/undefined.

Co-authored-by: Hug0-Drelon <69580439+Hug0-Drelon@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@github-actions
Copy link

github-actions bot commented Feb 3, 2026

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 westonruter.

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

Ensures that `wp.sanitize.stripTags( false )` returns the string "false", consistent with how non-null/undefined values are handled.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@github-actions
Copy link

github-actions bot commented Feb 3, 2026

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Updates `wp.sanitize.stripTags()` to return an empty string for all falsy values (0, false, NaN, etc.), restoring consistency with WordPress 6.9 behavior. Adds QUnit tests for these edge cases.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Copy link
Member

@sirreal sirreal left a comment

Choose a reason for hiding this comment

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

Thanks!

*/
stripTags: function( text ) {
if ( null === text || 'undefined' === typeof text ) {
if ( ! text ) {
Copy link
Member

Choose a reason for hiding this comment

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

That's easier 😆

pento pushed a commit that referenced this pull request Feb 3, 2026
…o return empty string when falsy value supplied.

Developed in #10856

Follow-up to [61578], [61347], [60907].

Props jonsurrell, hugod, westonruter.
See #64274.
Fixes #64574.


git-svn-id: https://develop.svn.wordpress.org/trunk@61585 602fd350-edb4-49c9-b593-d223f7449a82
@github-actions
Copy link

github-actions bot commented Feb 3, 2026

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 61585
GitHub commit: 4677c7a

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@github-actions github-actions bot closed this Feb 3, 2026
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Feb 3, 2026
…o return empty string when falsy value supplied.

Developed in WordPress/wordpress-develop#10856

Follow-up to [61578], [61347], [60907].

Props jonsurrell, hugod, westonruter.
See #64274.
Fixes #64574.

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


git-svn-id: http://core.svn.wordpress.org/trunk@60896 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.

2 participants