Ticket #48054: 48054.patch
File 48054.patch, 1.2 KB (added by , 5 years ago) |
---|
-
src/js/_enqueues/wp/sanitize.js
16 16 /** 17 17 * Strip HTML tags. 18 18 * 19 * @param {string} text Text to have the HTML tags strip ed out of.19 * @param {string} text Text to have the HTML tags stripped out of. 20 20 * 21 21 * @return Stripped text. 22 22 */ 23 23 stripTags: function( text ) { 24 text = text || '';24 var _text = text || ''; 25 25 26 // Do the replacement. 27 var _text = text 26 // Do the search-replace until there is nothing to be replaced. 27 do { 28 // Keep pre-replace text for comparison. 29 text = _text; 30 31 // Do the replacement. 32 _text = text 28 33 .replace( /<!--[\s\S]*?(-->|$)/g, '' ) 29 34 .replace( /<(script|style)[^>]*>[\s\S]*?(<\/\1>|$)/ig, '' ) 30 35 .replace( /<\/?[a-z][\s\S]*?(>|$)/ig, '' ); 36 } while ( _text !== text ); 31 37 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 }37 38 38 // Return the text with stripped tags. 39 39 return _text; 40 40 },