Refine wp.sanitize.stripTags() when input is an empty value#10856
Refine wp.sanitize.stripTags() when input is an empty value#10856westonruter wants to merge 4 commits intoWordPress:trunkfrom
wp.sanitize.stripTags() when input is an empty value#10856Conversation
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>
|
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 Core Committers: Use this line as a base for the props when committing in SVN: 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>
Test using WordPress PlaygroundThe 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
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
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>
| */ | ||
| stripTags: function( text ) { | ||
| if ( null === text || 'undefined' === typeof text ) { | ||
| if ( ! text ) { |
…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
…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
This further improves back-compat for
wp.sanitize.stripTags()when a falsy value is passed, includingfalse,0, andNaN. 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:
wp.sanitize.stripTags()when input isnullorundefined#10833 (comment)wp.sanitize.stripTags()when input isnullorundefined#10833 (comment)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.