Some problems happen after editing by FCKeditor.
For example:
1. Income data
<table border="1" width="100%">
2. Output result after saving in FCKeditor
<table border="\&quot;1\&quot;">
Some properties were removed.
3. Again try to edit previous result
4. Output result for the second saving
<table border="\&quot;\\&quot;1\\&quot;\&quot;">
Logged In: NO
Resolved this issue by editing HTMLEditorUI, so that the JavascriptEscape get's undone when pulling the html out:
public String getContent() {
// temporarily add a listener on the status text to retrieve the
// contents of the design editor
browser.addStatusTextListener(new StatusTextListener() {
public void changed(final StatusTextEvent event) {
browser.setData("content", event.text);
browser.removeStatusTextListener(this);
}
});
browser.execute("getContent()");
return unescape((String) browser.getData("content"));
}
private String unescape(String content) {
return StringEscapeUtils.unescapeJavaScript(content);
}
Addionally I altered fckconfig.js. So that no automatic conversion takes place.
FCKConfig.FormatSource = false ;
FCKConfig.FormatOutput = false ;
FCKConfig.ProcessHTMLEntities = false ;
FCKConfig.IncludeLatinEntities = false ;
FCKConfig.IncludeGreekEntities = false ;
FCKConfig.AutoDetectLanguage = false ;
Logged In: NO
Hallo,
I developed a HtmlContentEscaper to fix this issue. I commented already yesterday. This is fix of the fix ... . If you have questions: dschuma78@googlemail.com
It is integrated in the HtmlEditorUI:
private String escape(String content) {
String htmlEscape = new HtmlContentEscaper().escapeHtmlContent(content);
String scriptEscape = StringEscapeUtils.escapeJavaScript(htmlEscape);
return scriptEscape;
}
And here:
public String getContent() {
// temporarily add a listener on the status text to retrieve the
// contents of the design editor
browser.addStatusTextListener(new StatusTextListener() {
public void changed(final StatusTextEvent event) {
browser.setData("content", event.text);
browser.removeStatusTextListener(this);
}
});
browser.execute("getContent()");
return unescape((String) browser.getData("content"));
}
private String unescape(String content) {
String scriptUnescape = StringEscapeUtils.unescapeJavaScript(content);
String htmlUnescape = new HtmlContentEscaper().unescapeHtmlContent(scriptUnescape);
return htmlUnescape;
}
Here the HtmlContentEscaper itself:
package tools;
import org.apache.commons.lang.StringEscapeUtils;
public class HtmlContentEscaper {
public String unescapeHtmlContent(String html){
return transform(html, false);
}
public String escapeHtmlContent(String html){
return transform(html, true);
}
private String transform(String body, boolean escape){
StringBuffer ergebnis = new StringBuffer();
char[] chars = body.toCharArray();
StringBuffer umzuwandeln = new StringBuffer();
boolean imTag = false;
for (int i = 0; i < chars.length; i++) {
char c = chars[i];
if(c == '<'){
imTag = true;
if(escape){
ergebnis.append(StringEscapeUtils.escapeHtml(umzuwandeln.toString()));
}
else {
ergebnis.append(StringEscapeUtils.unescapeHtml(umzuwandeln.toString()));
}
ergebnis.append(c);
umzuwandeln = new StringBuffer();
}
else if( c == '>'){
imTag = false;
ergebnis.append(c);
}
else if(imTag){
ergebnis.append(c);
}
else if(!imTag) {
umzuwandeln.append(c);
}
}
return ergebnis.toString();
}
}
Best regards
Dirk Schumacher