#2272: FF3: Paste from word leaves lots of garbage tags
-----------------------+----------------------------------------------------
Reporter: joshclark | Type: Bug
Status: new | Priority: Normal
Milestone: | Component: UI : Dialogs
Version: | Keywords:
-----------------------+----------------------------------------------------
In Firefox 3 RC3, the "paste from word" feature leaves lots of garbage
tags behind. Specifically:
* It does not remove comments.[[BR]]
* It does not remove <style> elements.[[BR]]
* It does not remove <meta> elements.[[BR]]
* It does not remove <link> elements.
The comments issue can be fixed by changing this line in fck_paste.html's
CleanWord function:
{{{
html = html.replace(/<\!--.*?-->/g, '' ) ;
}}}
...to this:
{{{
html = html.replace(/<\!--[\s\S]*?-->/g, '' ) ;
}}}
(Because . does not match new lines, multi-line comments are not removed;
[\s\S] does the trick instead.)
To be safe, I recommend making similar changes to all of the
fck_paste.html instances where .* is used. Specifically, these lines:
{{{
html = html.replace(/<o:p>.*?<\/o:p>/g, ' ') ;
}}}
{{{
html = html.replace( /<SPAN\s*>(.*?)<\/SPAN>/gi, '$1' ) ;
html = html.replace( /<FONT\s*>(.*?)<\/FONT>/gi, '$1' ) ;
}}}
{{{
html = html.replace(
/<(\w+)[^>]*\sstyle="[^"]*DISPLAY\s?:\s?none(.*?)<\/\1>/ig, '' ) ;
}}}
{{{
html = html.replace( /<(H\d)><FONT[^>]*>(.*?)<\/FONT><\/\1>/gi,
'<$1>$2<\/$1>' );
html = html.replace( /<(H\d)><EM>(.*?)<\/EM><\/\1>/gi, '<$1>$2<\/$1>' );
}}}
{{{
var re = new RegExp( '(<P)([^>]*>.*?)(<\/P>)', 'gi' ) ; // Different
because of a IE 5.0 error
}}}
...should be changed respectively to:
{{{
html = html.replace(/<o:p>[\s\S]*?<\/o:p>/g, ' ') ;
}}}
{{{
html = html.replace( /<SPAN\s*>([\s\S]*?)<\/SPAN>/gi, '$1' ) ;
html = html.replace( /<FONT\s*>([\s\S]*?)<\/FONT>/gi, '$1' ) ;
}}}
{{{
html = html.replace(
/<(\w+)[^>]*\sstyle="[^"]*DISPLAY\s?:\s?none([\s\S]*?)<\/\1>/ig, '' ) ;
}}}
{{{
html = html.replace( /<(H\d)><FONT[^>]*>([\s\S]*?)<\/FONT><\/\1>/gi,
'<$1>$2<\/$1>' );
html = html.replace( /<(H\d)><EM>([\s\S]*?)<\/EM><\/\1>/gi, '<$1>$2<\/$1>'
);
}}}
{{{
var re = new RegExp( '(<P)([^>]*>[\s\S]*?)(<\/P>)', 'gi' ) ; //
Different because of a IE 5.0 error
}}}
Also, to get rid of the <meta>, <link> and <style> elements, I suggest
adding these additional replacements:
{{{
// Remove meta/link tags
html = html.replace(/<(META|LINK)[^>]*>\s*/gi, '' ) ;
// Remove style tags
html = html.replace( /<STYLE[^>]*>([\s\S]*?)<\/STYLE[^>]*>/gi, '' ) ;
}}}
--
Ticket URL: <http://dev.fckeditor.net/ticket/2272>
FCKeditor <http://www.fckeditor.net>
The text editor for Internet
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
FCKeditor-Trac mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fckeditor-trac