Correct encode text
apronin83 opened this issue · 0 comments
apronin83 commented
You have incorrect coding of the text of the node and attribute.
Your code (dom.js):
function _xmlEncoder(c){
return c == '<' && '<' ||
c == '>' && '>' ||
c == '&' && '&' ||
c == '"' && '"' ||
'&#'+c.charCodeAt()+';'
}
...
case ATTRIBUTE_NODE:
return buf.push(' ',node.name,'="',node.value.replace(/[<&"]/g,_xmlEncoder),'"');
case TEXT_NODE:
return buf.push(node.data.replace(/[<&]/g,_xmlEncoder));
My code (dom.js):
function _xmlEncoder(c) {
return c == '<' && '<' ||
c == '>' && '>' ||
c == '&' && '&' ||
c == '"' && '"' ||
c == "'" && ''';
}
...
case ATTRIBUTE_NODE:
return buf.push(' ',node.name,'="',node.value.replace(/[&"<>\']/g,_xmlEncoder),'"');
case TEXT_NODE:
return buf.push(node.data.replace(/[&"<>\']/g,_xmlEncoder));