Ticket #2272: 2272.patch

File 2272.patch, 3.5 KB (added by martinkou, 21 months ago)
  • _whatsnew.html

     
    6464                <li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/2322">#2322</a>] Fixed the issue 
    6565                        where the fit window command loses the current selection and scroll position in the 
    6666                        editing area.</li> 
     67                <li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/2272">#2272</a>] Improved the 
     68                        garbage filter in Paste from Word dialog.</li> 
    6769        </ul> 
    6870        <p> 
    6971                <a href="_whatsnew_history.html">See previous versions history</a></p> 
  • editor/dialog/fck_paste.html

     
    187187        var html = oNode.innerHTML ; 
    188188 
    189189        html = html.replace(/<o:p>\s*<\/o:p>/g, '') ; 
    190         html = html.replace(/<o:p>.*?<\/o:p>/g, '&nbsp;') ; 
     190        html = html.replace(/<o:p>[\s\S]*?<\/o:p>/g, '&nbsp;') ; 
    191191 
    192192        // Remove mso-xxx styles. 
    193193        html = html.replace( /\s*mso-[^:]+:[^;"]+;?/gi, '' ) ; 
     
    224224        if ( bRemoveStyles ) 
    225225                html = html.replace( /<(\w[^>]*) style="([^\"]*)"([^>]*)/gi, "<$1$3" ) ; 
    226226 
     227        // Remove style, meta and link tags 
     228        html = html.replace( /<STYLE[^>]*>[\s\S]*?<\/STYLE[^>]*>/gi, '' ) ; 
     229        html = html.replace( /<(?:META|LINK)[^>]*>\s*/gi, '' ) ; 
     230 
    227231        // Remove empty styles. 
    228232        html =  html.replace( /\s*style="\s*"/gi, '' ) ; 
    229233 
     
    234238        // Remove Lang attributes 
    235239        html = html.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3") ; 
    236240 
    237         html = html.replace( /<SPAN\s*>(.*?)<\/SPAN>/gi, '$1' ) ; 
     241        html = html.replace( /<SPAN\s*>([\s\S]*?)<\/SPAN>/gi, '$1' ) ; 
    238242 
    239         html = html.replace( /<FONT\s*>(.*?)<\/FONT>/gi, '$1' ) ; 
     243        html = html.replace( /<FONT\s*>([\s\S]*?)<\/FONT>/gi, '$1' ) ; 
    240244 
    241245        // Remove XML elements and declarations 
    242246        html = html.replace(/<\\?\?xml[^>]*>/gi, '' ) ; 
     
    245249        html = html.replace(/<\/?\w+:[^>]*>/gi, '' ) ; 
    246250 
    247251        // Remove comments [SF BUG-1481861]. 
    248         html = html.replace(/<\!--.*?-->/g, '' ) ; 
     252        html = html.replace(/<\!--[\s\S]*?-->/g, '' ) ; 
    249253 
    250254        html = html.replace( /<(U|I|STRIKE)>&nbsp;<\/\1>/g, '&nbsp;' ) ; 
    251255 
    252256        html = html.replace( /<H\d>\s*<\/H\d>/gi, '' ) ; 
    253257 
    254258        // Remove "display:none" tags. 
    255         html = html.replace( /<(\w+)[^>]*\sstyle="[^"]*DISPLAY\s?:\s?none(.*?)<\/\1>/ig, '' ) ; 
     259        html = html.replace( /<(\w+)[^>]*\sstyle="[^"]*DISPLAY\s?:\s?none[\s\S]*?<\/\1>/ig, '' ) ; 
    256260 
    257261        // Remove language tags 
    258262        html = html.replace( /<(\w[^>]*) language=([^ |>]*)([^>]*)/gi, "<$1$3") ; 
     
    267271                html = html.replace( /<H(\d)([^>]*)>/gi, '<h$1>' ) ; 
    268272 
    269273                // Word likes to insert extra <font> tags, when using MSIE. (Wierd). 
    270                 html = html.replace( /<(H\d)><FONT[^>]*>(.*?)<\/FONT><\/\1>/gi, '<$1>$2<\/$1>' ); 
    271                 html = html.replace( /<(H\d)><EM>(.*?)<\/EM><\/\1>/gi, '<$1>$2<\/$1>' ); 
     274                html = html.replace( /<(H\d)><FONT[^>]*>([\s\S]*?)<\/FONT><\/\1>/gi, '<$1>$2<\/$1>' ); 
     275                html = html.replace( /<(H\d)><EM>([\s\S]*?)<\/EM><\/\1>/gi, '<$1>$2<\/$1>' ); 
    272276        } 
    273277        else 
    274278        { 
     
    282286                html = html.replace( /<\/H\d>/gi, '<\/font><\/b><\/div>' ) ; 
    283287 
    284288                // Transform <P> to <DIV> 
    285                 var re = new RegExp( '(<P)([^>]*>.*?)(<\/P>)', 'gi' ) ; // Different because of a IE 5.0 error 
     289                var re = new RegExp( '(<P)([^>]*>[\\s\\S]*?)(<\/P>)', 'gi' ) ;  // Different because of a IE 5.0 error 
    286290                html = html.replace( re, '<div$2<\/div>' ) ; 
    287291 
    288292                // Remove empty tags (three times, just to be sure).