diff --git a/chrome/content/zotero/xpcom/storage/webdav.js b/chrome/content/zotero/xpcom/storage/webdav.js
index ca6c299791..fb6e7d8e5a 100644
--- a/chrome/content/zotero/xpcom/storage/webdav.js
+++ b/chrome/content/zotero/xpcom/storage/webdav.js
@@ -68,21 +68,15 @@ Zotero.Sync.Storage.WebDAV = (function () {
return false;
}
- try {
- var xml = new XML(req.responseText);
- }
- catch (e) {
- Zotero.debug(e);
- var xml = null;
- }
-
- if (xml) {
- Zotero.debug(xml.children().length());
- }
-
- if (xml && xml.children().length()) {
+ if (req.responseXML) {
// TODO: other stuff, but this makes us forward-compatible
- mtime = xml.mtime.toString();
+ try {
+ var mtime = req.responseXML.getElementsByTagName('mtime')[0]
+ }
+ catch (e) {
+ Zotero.debug(e);
+ var mtime = "";
+ }
var seconds = false;
}
else {
@@ -139,12 +133,12 @@ Zotero.Sync.Storage.WebDAV = (function () {
var mtime = item.attachmentModificationTime;
var hash = item.attachmentHash;
- var prop =
- {mtime}
- {hash}
- ;
+ var prop = ''
+ + '' + mtime + ''
+ + '' + hash + ''
+ + '';
- return Zotero.HTTP.promise("PUT", uri, prop.toXMLString(),
+ return Zotero.HTTP.promise("PUT", uri, prop,
{ debug: true, successCodes: [200, 201, 204] })
.then(function (req) {
return { mtime: mtime, hash: hash };
@@ -1130,16 +1124,10 @@ Zotero.Sync.Storage.WebDAV = (function () {
var requestHolder = { request: null };
- var prolog = '\n';
- var D = new Namespace("D", "DAV:");
- var nsDeclarations = 'xmlns:' + D.prefix + '=' + '"' + D.uri + '"';
-
- var requestXML = new XML('');
- requestXML.D::prop = '';
- // IIS 5.1 requires at least one property in PROPFIND
- requestXML.D::prop.D::getcontentlength = '';
-
- var xmlstr = prolog + requestXML.toXMLString();
+ var xmlstr = ""
+ // IIS 5.1 requires at least one property in PROPFIND
+ + ""
+ + "";
// Test whether URL is WebDAV-enabled
var request = Zotero.HTTP.doOptions(uri, function (req) {
@@ -1586,15 +1574,9 @@ Zotero.Sync.Storage.WebDAV = (function () {
var uri = this.rootURI;
var path = uri.path;
- var prolog = '\n';
- var D = new Namespace("D", "DAV:");
- var nsDeclarations = 'xmlns:' + D.prefix + '=' + '"' + D.uri + '"';
-
- var requestXML = new XML('');
- requestXML.D::prop = '';
- requestXML.D::prop.D::getlastmodified = '';
-
- var xmlstr = prolog + requestXML.toXMLString();
+ var xmlstr = ""
+ + ""
+ + "";
var lastSyncDate = new Date(Zotero.Sync.Server.lastLocalSyncTime * 1000);
@@ -1603,13 +1585,16 @@ Zotero.Sync.Storage.WebDAV = (function () {
var funcName = "Zotero.Sync.Storage.purgeOrphanedStorageFiles()";
- // Strip XML declaration and convert to E4X
- var xml = new XML(req.responseText.replace(/<\?xml.*\?>/, ''));
+ var responseNode = req.responseXML.documentElement;
+ responseNode.xpath = function (path) {
+ return Zotero.Utilities.xpath(this, path, { D: 'DAV:' });
+ };
var deleteFiles = [];
var trailingSlash = !!path.match(/\/$/);
- for each(var response in xml.D::response) {
- var href = response.D::href.toString();
+ for each(var response in responseNode.xpath("response")) {
+ var href = Zotero.Utilities.xpath(response, "href", { D: 'DAV:' });
+ href = href.length ? href[0] : ''
// Strip trailing slash if there isn't one on the root path
if (!trailingSlash) {
@@ -1672,7 +1657,10 @@ Zotero.Sync.Storage.WebDAV = (function () {
Zotero.debug("Checking orphaned file " + file);
// TODO: Parse HTTP date properly
- var lastModified = response..*::getlastmodified.toString();
+ var lastModified = Zotero.Utilities.xpath(
+ response, "//getlastmodified", { D: 'DAV:' }
+ );
+ lastModified = lastModified.length ? lastModified[0] : ''
lastModified = Zotero.Date.strToISO(lastModified);
lastModified = Zotero.Date.sqlToDate(lastModified);
diff --git a/chrome/content/zotero/xpcom/storage/zfs.js b/chrome/content/zotero/xpcom/storage/zfs.js
index bbf76d1d54..e2c6dbf50c 100644
--- a/chrome/content/zotero/xpcom/storage/zfs.js
+++ b/chrome/content/zotero/xpcom/storage/zfs.js
@@ -237,31 +237,29 @@ Zotero.Sync.Storage.ZFS = (function () {
return Zotero.HTTP.promise("POST", uri, { body: body, debug: true })
.then(function (req) {
- try {
- // Strip XML declaration and convert to E4X
- var xml = new XML(Zotero.Utilities.trim(req.responseText.replace(/<\?xml.*\?>/, '')));
- }
- catch (e) {
+ if (!req.responseXML) {
throw new Error("Invalid response retrieving file upload parameters");
}
- if (xml.name() != 'upload' && xml.name() != 'exists') {
+ var rootTag = req.responseXML.documentElement.tagName;
+
+ if (rootTag != 'upload' && rootTag != 'exists') {
throw new Error("Invalid response retrieving file upload parameters");
}
// File was already available, so uploading isn't required
- if (xml.name() == 'exists') {
+ if (rootTag == 'exists') {
existsCallback();
return false;
}
- var url = xml.url.toString();
- var uploadKey = xml.key.toString();
+ var url = req.responseXML.getElementsByTagName('url')[0].textContent;
+ var uploadKey = req.responseXML.getElementsByTagName('key')[0].textContent;
var params = {}, p = '';
- for each(var param in xml.params.children()) {
- params[param.name()] = param.toString();
+ var paramNodes = req.responseXML.getElementsByTagName('params')[0].childNodes;
+ for (var i = 0; i < paramNodes.length; i++) {
+ params[paramNodes[i].tagName] = paramNodes[i].textContent;
}
- Zotero.debug(params);
return uploadCallback(item, url, uploadKey, params);
})
.fail(function (e) {