Changeset 60907
- Timestamp:
- 10/06/2025 11:44:48 PM (3 days ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/js/_enqueues/wp/sanitize.js
r59714 r60907 2 2 * @output wp-includes/js/wp-sanitize.js 3 3 */ 4 5 /* eslint-env es6 */ 4 6 5 7 ( function () { … … 17 19 * Strip HTML tags. 18 20 * 19 * @param {string} text Text to strip the HTML tags from.21 * @param {string} text - Text to strip the HTML tags from. 20 22 * 21 * @return Stripped text.23 * @return {string} Stripped text. 22 24 */ 23 25 stripTags: function( text ) { 24 text = text || '';26 let _text = text || ''; 25 27 26 // Do the replacement. 27 var _text = text 28 // Do the search-replace until there is nothing to be replaced. 29 do { 30 // Keep pre-replace text for comparison. 31 text = _text; 32 33 // Do the replacement. 34 _text = text 28 35 .replace( /<!--[\s\S]*?(-->|$)/g, '' ) 29 36 .replace( /<(script|style)[^>]*>[\s\S]*?(<\/\1>|$)/ig, '' ) 30 37 .replace( /<\/?[a-z][\s\S]*?(>|$)/ig, '' ); 31 32 // If the initial text is not equal to the modified text, 33 // do the search-replace again, until there is nothing to be replaced. 34 if ( _text !== text ) { 35 return wp.sanitize.stripTags( _text ); 36 } 38 } while ( _text !== text ); 37 39 38 40 // Return the text with stripped tags. … … 43 45 * Strip HTML tags and convert HTML entities. 44 46 * 45 * @param {string} text Text to strip tags and convert HTML entities.47 * @param {string} text - Text to strip tags and convert HTML entities. 46 48 * 47 * @return Sanitized text. False on failure.49 * @return {string} Sanitized text. 48 50 */ 49 51 stripTagsAndEncodeText: function( text ) { 50 var_text = wp.sanitize.stripTags( text ),52 let _text = wp.sanitize.stripTags( text ), 51 53 textarea = document.createElement( 'textarea' ); 52 54
Note: See TracChangeset for help on using the changeset viewer.