js/tinymce/plugins/paste/plugin.js
function trimHtml(html) {
      function trimSpaces(all, s1, s2) {
        // WebKit &nbsp; meant to preserve multiple spaces but instead inserted around all inline tags,
        // including the spans with inline styles created on paste
        if (!s1 && !s2) {
          return ' ';
        }

        return '\u00a0';
      }

      html = filter(html, [
        /^[\s\S]*<body[^>]*>\s*|\s*<\/body[^>]*>[\s\S]*$/ig, // Remove anything but the contents within the BODY element
        /<!--StartFragment-->|<!--EndFragment-->/g, // Inner fragments (tables from excel on mac)
        [/( ?)<span class="Apple-converted-space">\u00a0<\/span>( ?)/g, trimSpaces],
        /<br class="Apple-interchange-newline">/g,
        /<br>$/i // Trailing BR elements
      ]);

      return html;
    }
function trimHtml(html) {
      function trimSpaces(all, s1, s2) {
        // WebKit &nbsp; meant to preserve multiple spaces but instead inserted around all inline tags,
        // including the spans with inline styles created on paste
        if (!s1 && !s2) {
          return ' ';
        }

        return '\u00a0';
      }

      html = filter(html, [
        /^[\s\S]*<body[^>]*>\s*|\s*<\/body[^>]*>[\s\S]*$/ig, // Remove anything but the contents within the BODY element
        /<!--StartFragment-->|<!--EndFragment-->/g, // Inner fragments (tables from excel on mac)
        [/( ?)<span class="Apple-converted-space">\u00a0<\/span>( ?)/g, trimSpaces],
        /<br class="Apple-interchange-newline">/g,
        /<br>$/i // Trailing BR elements
      ]);

      return html;
    }
function trimHtml ( html ) { function trimSpaces ( all , s1 , s2 ) { // WebKit &nbsp; meant to preserve multiple spaces but instead inserted around all inline tags, // including the spans with inline styles created on paste if ( ! s1 && ! s2 ) { return ' ' ; } return '\u00a0' ; } html = filter ( html , [ / ^[\s\S]*<body[^>]*>\s*|\s*<\/body[^>]*>[\s\S]*$ / ig , // Remove anything but the contents within the BODY element / <!--StartFragment-->|<!--EndFragment--> / g , // Inner fragments (tables from excel on mac) [ / ( ?)<span class="Apple-converted-space">\u00a0<\/span>( ?) / g , trimSpaces ] , / <br class="Apple-interchange-newline"> / g , / <br>$ / i // Trailing BR elements ] ) ; return html ; }
Trims the specified HTML by removing all WebKit fragments, all elements wrapping the body trailing BR elements etc.

@param {String} html Html string to trim contents on.
@return {String} Html contents that got trimmed.
Trims the specified HTML by removing all WebKit fragments all elements wrapping the body trailing BR elements etc .