summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2015-11-24 11:59:00 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2015-11-24 15:26:53 +0100
commitb1ca43185246f437a54626b8dd56c157639d46ec (patch)
tree359212b45946778a4421321139df77ca9ad0ca57 /core
parentae36c01b959d1cbdaeabb46d30cb416aae428a88 (diff)
downloadnextcloud-server-b1ca43185246f437a54626b8dd56c157639d46ec.tar.gz
nextcloud-server-b1ca43185246f437a54626b8dd56c157639d46ec.zip
Fix for parsing pretty printed Webdav responses
Update davclient.js + adjust IE workaround for this
Diffstat (limited to 'core')
-rw-r--r--core/js/files/iedavclient.js5
-rw-r--r--core/vendor/davclient.js/lib/client.js33
2 files changed, 29 insertions, 9 deletions
diff --git a/core/js/files/iedavclient.js b/core/js/files/iedavclient.js
index bc6bce2f9ae..4fd9a3a3bf4 100644
--- a/core/js/files/iedavclient.js
+++ b/core/js/files/iedavclient.js
@@ -145,10 +145,7 @@
var k = 0;
for (k = 0; k < propNode.childNodes.length; k++) {
var prop = propNode.childNodes[k];
- var value = prop.textContent || prop.text;
- if (prop.childNodes && prop.childNodes.length > 0 && prop.childNodes[0].nodeType === 1) {
- value = prop.childNodes;
- }
+ var value = this._parsePropNode(prop);
propStat.properties['{' + prop.namespaceURI + '}' + (prop.localName || prop.baseName)] = value;
}
diff --git a/core/vendor/davclient.js/lib/client.js b/core/vendor/davclient.js/lib/client.js
index 121b5dcab5f..18bbf13f3cd 100644
--- a/core/vendor/davclient.js/lib/client.js
+++ b/core/vendor/davclient.js/lib/client.js
@@ -148,6 +148,33 @@ dav.Client.prototype = {
},
+ /**
+ * Parses a property node.
+ *
+ * Either returns a string if the node only contains text, or returns an
+ * array of non-text subnodes.
+ *
+ * @param {Object} propNode node to parse
+ * @return {string|Array} text content as string or array of subnodes, excluding text nodes
+ */
+ _parsePropNode: function(propNode) {
+ var content = null;
+ if (propNode.childNodes && propNode.childNodes.length > 0) {
+ var subNodes = [];
+ // filter out text nodes
+ for (var j = 0; j < propNode.childNodes.length; j++) {
+ var node = propNode.childNodes[j];
+ if (node.nodeType === 1) {
+ subNodes.push(node);
+ }
+ }
+ if (subNodes.length) {
+ content = subNodes;
+ }
+ }
+
+ return content || propNode.textContent || propNode.text;
+ },
/**
* Parses a multi-status response body.
@@ -197,11 +224,7 @@ dav.Client.prototype = {
var propNode = propIterator.iterateNext();
while(propNode) {
- var content = propNode.textContent;
- if (propNode.childNodes && propNode.childNodes.length > 0 && propNode.childNodes[0].nodeType === 1) {
- content = propNode.childNodes;
- }
-
+ var content = this._parsePropNode(propNode);
propStat.properties['{' + propNode.namespaceURI + '}' + propNode.localName] = content;
propNode = propIterator.iterateNext();