WebFX WebBoard
Message Thread:
View All Messages
Back to WebFX
 richedit getXHTML bug, andot, October 25, 2002
     Re:richedit getXHTML bug, Erik Arvidsson, October 25, 2002
         Re:richedit getXHTML bug, andot, October 26, 2002
             Re:richedit getXHTML bug, Erik Arvidsson, October 27, 2002
                 Re:richedit getXHTML bug , andot, October 28, 2002
                     Re:richedit getXHTML bug , Erik Arvidsson, October 28, 2002
                 Re:richedit getXHTML bug, andot, October 28, 2002
             Re:richedit getXHTML bug, Erik Arvidsson, October 27, 2002
                 Re:richedit getXHTML bug, andot, October 28, 2002

Subject: Re:richedit getXHTML bug From: Erik Arvidsson Date: October 25, 2002
You are correct that '>' does not need to be replaced in character data. However there is nothing special with attributes starting with "on" in XML. Your code will generate XML that is not well formed and the result will not parse.

Notice that replacing '>' with ">" is correct (but not necessary).

If you are having problem with ">" in your attributes you are not using a compliant XML parser/engine. If this is the case you are better of changing the fixAttribute function.

function _fixAttribute(s) {
return String(s).replace(/\&/g, "&amp;").replace(/</g, "&lt;").replace(/\"/g, "&quot;");
}

function _fixText(s) {
return String(s).replace(/\&/g, "&amp;").replace(/</g, "&lt;");
}

erik

-------------------------------------------------------

when I use event Attribute in the HTML tags, just like
<button onclick="if (something>0) alert('wrong!');">ok</button>
, the getXHTML method always fix the ">" into "&gt;", but it fix wrong. I think the event Attribute needn't to fix, so I modify the function _appendNodeXHTML(node, sb) in js/getxhtml.js. the following is modified part,
for (var i = 0; i < l; i++) {
if (attrs[i].specified) {
if (attrs[i].nodeName != "style") {
sb.append(" " + (attrs[i].expando ? attrs[i].nodeName : attrs[i].nodeName.toLowerCase()) +
"=\"" + ((attrs[i].nodeName.substring(0, 2) == "on") ? attrs[i].nodeValue : _fixAttribute(attrs[i].nodeValue)) + "\"");
}
else sb.append(" style=\"" + _fixAttribute(node.style.cssText).toLowerCase() + "\"");
}
}




Reply
Name: 
Email: 
Subject: 

Enter your reply to this message below. HTML tags are not supported but words that start with http://, ftp:// or mailto: are converted to links.


View All Messages
Back to WebFX