mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-10 20:44:28 +09:00
Fix escaped XML content: cf. xpressengine/xe-core#2042
This commit is contained in:
parent
8147044802
commit
f0d52f8a91
1 changed files with 12 additions and 5 deletions
|
|
@ -442,7 +442,7 @@ function xml2json(xml, tab, ignoreAttrib) {
|
||||||
X.removeWhite(xml);
|
X.removeWhite(xml);
|
||||||
for (var n1=xml.firstChild; n1; n1=n1.nextSibling) {
|
for (var n1=xml.firstChild; n1; n1=n1.nextSibling) {
|
||||||
if (n1.nodeType == 3) { // text node
|
if (n1.nodeType == 3) { // text node
|
||||||
o = X.escape(n1.nodeValue);
|
o = X.unescape(X.escape(n1.nodeValue));
|
||||||
} else if (n1.nodeType == 4) { // cdata node
|
} else if (n1.nodeType == 4) { // cdata node
|
||||||
// o["#cdata"] = X.escape(n.nodeValue);
|
// o["#cdata"] = X.escape(n.nodeValue);
|
||||||
o = X.escape(n1.nodeValue);
|
o = X.escape(n1.nodeValue);
|
||||||
|
|
@ -459,16 +459,16 @@ function xml2json(xml, tab, ignoreAttrib) {
|
||||||
}
|
}
|
||||||
else { // mixed content
|
else { // mixed content
|
||||||
if (!xml.attributes.length) {
|
if (!xml.attributes.length) {
|
||||||
o = X.escape(X.innerXml(xml));
|
o = X.unescape(X.escape(X.innerXml(xml)));
|
||||||
} else {
|
} else {
|
||||||
o["#text"] = X.escape(X.innerXml(xml));
|
o["#text"] = X.unescape(X.escape(X.innerXml(xml)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (textChild) { // pure text
|
} else if (textChild) { // pure text
|
||||||
if (!xml.attributes.length) {
|
if (!xml.attributes.length) {
|
||||||
o = X.escape(X.innerXml(xml));
|
o = X.unescape(X.escape(X.innerXml(xml)));
|
||||||
} else {
|
} else {
|
||||||
o["#text"] = X.escape(X.innerXml(xml));
|
o["#text"] = X.unescape(X.escape(X.innerXml(xml)));
|
||||||
}
|
}
|
||||||
} else if (cdataChild) { // cdata
|
} else if (cdataChild) { // cdata
|
||||||
if (cdataChild > 1) {
|
if (cdataChild > 1) {
|
||||||
|
|
@ -558,6 +558,13 @@ function xml2json(xml, tab, ignoreAttrib) {
|
||||||
.replace(/[\n]/g, '\\n')
|
.replace(/[\n]/g, '\\n')
|
||||||
.replace(/[\r]/g, '\\r');
|
.replace(/[\r]/g, '\\r');
|
||||||
},
|
},
|
||||||
|
unescape: function(txt) {
|
||||||
|
if (!navigator.userAgent.match(/Trident\/7.0/)) {
|
||||||
|
return txt.replace(/&/g, '&').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>');
|
||||||
|
} else {
|
||||||
|
return txt;
|
||||||
|
}
|
||||||
|
},
|
||||||
removeWhite: function(e) {
|
removeWhite: function(e) {
|
||||||
e.normalize();
|
e.normalize();
|
||||||
for (var n3 = e.firstChild; n3; ) {
|
for (var n3 = e.firstChild; n3; ) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue