From b97c2213b648aa178b1f723ec1e73ffe2a00af1d Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 2 Sep 2010 03:14:14 +0000 Subject: [PATCH] Commons: - Encode apostrophes, since IA wants it that way - Allow uploading only for regular items with attached files - Fix error if no local item --- chrome/content/zotero/xpcom/commons.js | 52 +++++++++++++++++--------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/chrome/content/zotero/xpcom/commons.js b/chrome/content/zotero/xpcom/commons.js index 9d7777803..8b4cdcdfc 100644 --- a/chrome/content/zotero/xpcom/commons.js +++ b/chrome/content/zotero/xpcom/commons.js @@ -369,6 +369,11 @@ Zotero.Commons = new function() { } + this.encodeURIComponent = function (str) { + return encodeURIComponent(str).replace("'", '%27'); + } + + this.error = function (message) { Components.utils.reportError(message); var prompt = Components.classes["@mozilla.org/network/default-prompt;1"] @@ -507,6 +512,8 @@ Zotero.Commons.Bucket.prototype.getItems = function (callback) { var zipsXML = xml.file.(@source == 'original').(typeof format != 'undefined' && format == 'Zotero ZIP Item'); } catch (e) { + alert("Invalid XML response retrieving file upload parameters"); + this._itemsLoading = false; return; } @@ -728,20 +735,31 @@ Zotero.Commons.Bucket.prototype.uploadItems = function (ids) { return; } - var itemsToUpload = false; + var itemsToUpload = []; + itemLoop: for (var i=0, len=items.length; i 1) { - throw ("Commons: More than one local item linked to remote item " + uri); + Zotero.debug("More than one local item linked to remote item " + uri, 2); + return false; } var item = Zotero.URI.getURIItem(rels[0].subject); if (!item) { - Zotero.debug("Linked local item not found for URI " + this.uri, 2); + Zotero.debug("Linked local item not found for remote URI " + uri, 2); return false; }