Escape the contents and attributes of xml when serializing

upd4.2
Brian Broll 2017-11-10 11:25:02 -06:00
rodzic 7c2d505df9
commit 5871bc6d69
1 zmienionych plików z 2 dodań i 2 usunięć

4
xml.js
Wyświetl plik

@ -238,7 +238,7 @@ XML_Element.prototype.toString = function (isFormatted, indentationLevel) {
for (key in this.attributes) {
if (Object.prototype.hasOwnProperty.call(this.attributes, key)
&& this.attributes[key]) {
result += ' ' + key + '="' + this.attributes[key] + '"';
result += ' ' + key + '="' + this.escape(this.attributes[key]) + '"';
}
}
@ -247,7 +247,7 @@ XML_Element.prototype.toString = function (isFormatted, indentationLevel) {
result += '/>';
} else {
result += '>';
result += this.contents;
result += this.escape(this.contents);
this.children.forEach(function (element) {
if (isFormatted) {
result += '\n';