Make WordPress Core

Ticket #48054: 48054.patch

File 48054.patch, 1.2 KB (added by sabernhardt, 5 years ago)

applying changes to /js/_enqueues/wp/sanitize.js

  • src/js/_enqueues/wp/sanitize.js

     
    1616                /**
    1717                 * Strip HTML tags.
    1818                 *
    19                  * @param {string} text Text to have the HTML tags striped out of.
     19                 * @param {string} text Text to have the HTML tags stripped out of.
    2020                 *
    2121                 * @return  Stripped text.
    2222                 */
    2323                stripTags: function( text ) {
    24                         text = text || '';
     24                        var _text = text || '';
    2525
    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
    2833                                        .replace( /<!--[\s\S]*?(-->|$)/g, '' )
    2934                                        .replace( /<(script|style)[^>]*>[\s\S]*?(<\/\1>|$)/ig, '' )
    3035                                        .replace( /<\/?[a-z][\s\S]*?(>|$)/ig, '' );
     36                        } while ( _text !== text );
    3137
    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 
    3838                        // Return the text with stripped tags.
    3939                        return _text;
    4040                },