From 5b1fa1218554ffafa2e6ed975da4e8ddef5d9112 Mon Sep 17 00:00:00 2001 From: SirLouen Date: Sat, 14 Jun 2025 14:35:05 +0200 Subject: [PATCH 1/4] Refreshing 48054.patch --- src/js/_enqueues/wp/sanitize.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/js/_enqueues/wp/sanitize.js b/src/js/_enqueues/wp/sanitize.js index 13f9045024f74..4260f74074e5c 100644 --- a/src/js/_enqueues/wp/sanitize.js +++ b/src/js/_enqueues/wp/sanitize.js @@ -21,19 +21,19 @@ * @return Stripped text. */ stripTags: function( text ) { - text = text || ''; + var _text = text || ''; - // Do the replacement. - var _text = text + // Do the search-replace until there is nothing to be replaced. + do { + // Keep pre-replace text for comparison. + text = _text; + + // Do the replacement. + _text = text .replace( /|$)/g, '' ) .replace( /<(script|style)[^>]*>[\s\S]*?(<\/\1>|$)/ig, '' ) .replace( /<\/?[a-z][\s\S]*?(>|$)/ig, '' ); - - // If the initial text is not equal to the modified text, - // do the search-replace again, until there is nothing to be replaced. - if ( _text !== text ) { - return wp.sanitize.stripTags( _text ); - } + } while ( _text !== text ); // Return the text with stripped tags. return _text; From addb7692fa81ff10a2f406b14e8488133ab88af6 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Mon, 6 Oct 2025 16:20:05 -0700 Subject: [PATCH 2/4] Use let instead of var --- src/js/_enqueues/wp/sanitize.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/js/_enqueues/wp/sanitize.js b/src/js/_enqueues/wp/sanitize.js index 4260f74074e5c..d23c64f96b4df 100644 --- a/src/js/_enqueues/wp/sanitize.js +++ b/src/js/_enqueues/wp/sanitize.js @@ -2,6 +2,8 @@ * @output wp-includes/js/wp-sanitize.js */ +/* eslint-env es6 */ + ( function () { window.wp = window.wp || {}; @@ -21,7 +23,7 @@ * @return Stripped text. */ stripTags: function( text ) { - var _text = text || ''; + let _text = text || ''; // Do the search-replace until there is nothing to be replaced. do { @@ -47,7 +49,7 @@ * @return Sanitized text. False on failure. */ stripTagsAndEncodeText: function( text ) { - var _text = wp.sanitize.stripTags( text ), + let _text = wp.sanitize.stripTags( text ), textarea = document.createElement( 'textarea' ); try { From 8dc0738a0bb6e2bd9311556bd13eca947a727ab6 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Mon, 6 Oct 2025 16:21:29 -0700 Subject: [PATCH 3/4] Fix whitespace --- src/js/_enqueues/wp/sanitize.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/js/_enqueues/wp/sanitize.js b/src/js/_enqueues/wp/sanitize.js index d23c64f96b4df..1a94a55e2451f 100644 --- a/src/js/_enqueues/wp/sanitize.js +++ b/src/js/_enqueues/wp/sanitize.js @@ -25,9 +25,9 @@ stripTags: function( text ) { let _text = text || ''; - // Do the search-replace until there is nothing to be replaced. - do { - // Keep pre-replace text for comparison. + // Do the search-replace until there is nothing to be replaced. + do { + // Keep pre-replace text for comparison. text = _text; // Do the replacement. From 542780542c2a7ffc5222e39d9ecb177799a7cc18 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Mon, 6 Oct 2025 16:22:47 -0700 Subject: [PATCH 4/4] Fix jsdoc return tags --- src/js/_enqueues/wp/sanitize.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/js/_enqueues/wp/sanitize.js b/src/js/_enqueues/wp/sanitize.js index 1a94a55e2451f..4252d0a014f7a 100644 --- a/src/js/_enqueues/wp/sanitize.js +++ b/src/js/_enqueues/wp/sanitize.js @@ -18,9 +18,9 @@ /** * Strip HTML tags. * - * @param {string} text Text to strip the HTML tags from. + * @param {string} text - Text to strip the HTML tags from. * - * @return Stripped text. + * @return {string} Stripped text. */ stripTags: function( text ) { let _text = text || ''; @@ -44,9 +44,9 @@ /** * Strip HTML tags and convert HTML entities. * - * @param {string} text Text to strip tags and convert HTML entities. + * @param {string} text - Text to strip tags and convert HTML entities. * - * @return Sanitized text. False on failure. + * @return {string} Sanitized text. */ stripTagsAndEncodeText: function( text ) { let _text = wp.sanitize.stripTags( text ),