diff options
author | blizzz <blizzz@arthur-schiwon.de> | 2017-12-11 17:12:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-11 17:12:02 +0100 |
commit | 4fc8984d8933b313e20acf80a4f08a7aafd1c1f0 (patch) | |
tree | 2429d6b589ab870a5e8548b1bd34714be79ced08 /core/js/files | |
parent | d0ec0ce71c62465204fe4fddc2d4f406afc99730 (diff) | |
parent | dfc91a253c19746b1062189740242c5b1992c7a5 (diff) | |
download | nextcloud-server-4fc8984d8933b313e20acf80a4f08a7aafd1c1f0.tar.gz nextcloud-server-4fc8984d8933b313e20acf80a4f08a7aafd1c1f0.zip |
Merge pull request #6079 from nextcloud/fix-antivirus
Parse Sabre Exception in OC.Files.Client and file-upload
Diffstat (limited to 'core/js/files')
-rw-r--r-- | core/js/files/client.js | 47 |
1 files changed, 37 insertions, 10 deletions
diff --git a/core/js/files/client.js b/core/js/files/client.js index dc842a9d3bf..0109ab9fdbf 100644 --- a/core/js/files/client.js +++ b/core/js/files/client.js @@ -410,6 +410,26 @@ }, /** + * Parse the Sabre exception out of the given response, if any + * + * @param {Object} response object + * @return {Object} array of parsed message and exception (only the first one) + */ + _getSabreException: function(response) { + var result = {}; + var xml = response.xhr.responseXML; + var messages = xml.getElementsByTagNameNS('http://sabredav.org/ns', 'message'); + var exceptions = xml.getElementsByTagNameNS('http://sabredav.org/ns', 'exception'); + if (messages.length) { + result.message = messages[0].textContent; + } + if (exceptions.length) { + result.exception = exceptions[0].textContent; + } + return result; + }, + + /** * Returns the default PROPFIND properties to use during a call. * * @return {Array.<Object>} array of properties @@ -462,7 +482,8 @@ } deferred.resolve(result.status, results); } else { - deferred.reject(result.status); + result = _.extend(result, self._getSabreException(result)); + deferred.reject(result.status, result); } }); return promise; @@ -536,7 +557,8 @@ var results = self._parseResult(result.body); deferred.resolve(result.status, results); } else { - deferred.reject(result.status); + result = _.extend(result, self._getSabreException(result)); + deferred.reject(result.status, result); } }); return promise; @@ -575,7 +597,8 @@ if (self._isSuccessStatus(result.status)) { deferred.resolve(result.status, self._parseResult([result.body])[0]); } else { - deferred.reject(result.status); + result = _.extend(result, self._getSabreException(result)); + deferred.reject(result.status, result); } } ); @@ -605,7 +628,8 @@ if (self._isSuccessStatus(result.status)) { deferred.resolve(result.status, result.body); } else { - deferred.reject(result.status); + result = _.extend(result, self._getSabreException(result)); + deferred.reject(result.status, result); } } ); @@ -654,7 +678,8 @@ if (self._isSuccessStatus(result.status)) { deferred.resolve(result.status); } else { - deferred.reject(result.status); + result = _.extend(result, self._getSabreException(result)); + deferred.reject(result.status, result); } } ); @@ -678,7 +703,8 @@ if (self._isSuccessStatus(result.status)) { deferred.resolve(result.status); } else { - deferred.reject(result.status); + result = _.extend(result, self._getSabreException(result)); + deferred.reject(result.status, result); } } ); @@ -742,11 +768,12 @@ this._buildUrl(path), headers ).then( - function(response) { - if (self._isSuccessStatus(response.status)) { - deferred.resolve(response.status); + function(result) { + if (self._isSuccessStatus(result.status)) { + deferred.resolve(result.status); } else { - deferred.reject(response.status); + result = _.extend(result, self._getSabreException(result)); + deferred.reject(result.status, result); } } ); |