Ticket #2272: 2272_2.patch

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

     
    6767                <li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/2322">#2322</a>] Fixed the issue 
    6868                        where the fit window command loses the current selection and scroll position in the 
    6969                        editing area.</li> 
     70                <li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/2272">#2272</a>] Improved the 
     71                        garbage filter in Paste from Word dialog.</li> 
    7072        </ul> 
    7173        <p> 
    7274                <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, '' ) ; 
    243247 
     248        // Remove w: tags with contents. 
     249        html = html.replace( /<w:[^>]*>[\s\S]*?<\/w:[^>]*>/gi, '' ) ; 
     250 
    244251        // Remove Tags with XML namespace declarations: <o:p><\/o:p> 
    245252        html = html.replace(/<\/?\w+:[^>]*>/gi, '' ) ; 
    246253 
    247254        // Remove comments [SF BUG-1481861]. 
    248         html = html.replace(/<\!--.*?-->/g, '' ) ; 
     255        html = html.replace(/<\!--[\s\S]*?-->/g, '' ) ; 
    249256 
    250257        html = html.replace( /<(U|I|STRIKE)>&nbsp;<\/\1>/g, '&nbsp;' ) ; 
    251258 
    252259        html = html.replace( /<H\d>\s*<\/H\d>/gi, '' ) ; 
    253260 
    254261        // Remove "display:none" tags. 
    255         html = html.replace( /<(\w+)[^>]*\sstyle="[^"]*DISPLAY\s?:\s?none(.*?)<\/\1>/ig, '' ) ; 
     262        html = html.replace( /<(\w+)[^>]*\sstyle="[^"]*DISPLAY\s?:\s?none[\s\S]*?<\/\1>/ig, '' ) ; 
    256263 
    257264        // Remove language tags 
    258265        html = html.replace( /<(\w[^>]*) language=([^ |>]*)([^>]*)/gi, "<$1$3") ; 
     
    267274                html = html.replace( /<H(\d)([^>]*)>/gi, '<h$1>' ) ; 
    268275 
    269276                // 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>' ); 
     277                html = html.replace( /<(H\d)><FONT[^>]*>([\s\S]*?)<\/FONT><\/\1>/gi, '<$1>$2<\/$1>' ); 
     278                html = html.replace( /<(H\d)><EM>([\s\S]*?)<\/EM><\/\1>/gi, '<$1>$2<\/$1>' ); 
    272279        } 
    273280        else 
    274281        { 
     
    282289                html = html.replace( /<\/H\d>/gi, '<\/font><\/b><\/div>' ) ; 
    283290 
    284291                // Transform <P> to <DIV> 
    285                 var re = new RegExp( '(<P)([^>]*>.*?)(<\/P>)', 'gi' ) ; // Different because of a IE 5.0 error 
     292                var re = new RegExp( '(<P)([^>]*>[\\s\\S]*?)(<\/P>)', 'gi' ) ;  // Different because of a IE 5.0 error 
    286293                html = html.replace( re, '<div$2<\/div>' ) ; 
    287294 
    288295                // Remove empty tags (three times, just to be sure).