From dbe7640f185b5a031e4d09a999e26bdef2b07155 Mon Sep 17 00:00:00 2001 From: Florian Martin-Bariteau Date: Tue, 24 Jun 2014 22:55:56 -0400 Subject: [PATCH 01/87] Allow QuickSearch to search for civil law cases --- chrome/content/zotero/xpcom/search.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/chrome/content/zotero/xpcom/search.js b/chrome/content/zotero/xpcom/search.js index a351ed73c..7ef6c6f9e 100644 --- a/chrome/content/zotero/xpcom/search.js +++ b/chrome/content/zotero/xpcom/search.js @@ -420,6 +420,8 @@ Zotero.Search.prototype.addCondition = function(condition, operator, value, requ if (condition == 'quicksearch-titleCreatorYear') { this.addCondition('title', operator, part.text, false); this.addCondition('publicationTitle', operator, part.text, false); + this.addCondition('shortTitle', operator, part.text, false); + this.addCondition('court', operator, part.text, false); this.addCondition('year', operator, part.text, false); } else { From 9cd7423dd7fae6894fd601b46502b87b51258270 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 2 Sep 2014 23:28:20 -0400 Subject: [PATCH 02/87] Change cert error message URL to https:// --- chrome/content/zotero/xpcom/sync.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/sync.js b/chrome/content/zotero/xpcom/sync.js index 43d5356d1..185ef41ed 100644 --- a/chrome/content/zotero/xpcom/sync.js +++ b/chrome/content/zotero/xpcom/sync.js @@ -1974,7 +1974,7 @@ Zotero.Sync.Server = new function () { catch (e) { Zotero.debug(e); } - var kbURL = 'http://zotero.org/support/kb/ssl_certificate_error'; + var kbURL = 'https://zotero.org/support/kb/ssl_certificate_error'; _error(Zotero.getString('sync.storage.error.webdav.sslCertificateError', host) + "\n\n" + Zotero.getString('general.seeForMoreInformation', kbURL), false, noReloadOnFailure); From 55f86f4295eb1784afc5ed47c6f5961979709087 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Fri, 5 Sep 2014 00:27:59 -0400 Subject: [PATCH 03/87] Fix error handling for saveItems --- chrome/content/zotero/xpcom/server_connector.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/server_connector.js b/chrome/content/zotero/xpcom/server_connector.js index f52633b20..f44772600 100644 --- a/chrome/content/zotero/xpcom/server_connector.js +++ b/chrome/content/zotero/xpcom/server_connector.js @@ -370,8 +370,8 @@ Zotero.Server.Connector.SaveItem.prototype = { sendResponseCallback(500); } } else { + Zotero.logError(items); sendResponseCallback(500); - throw newItems; } }, Zotero.Server.Connector.AttachmentProgressManager.onProgress); } From 61d7bd852b462767893a1e53888c9579933af755 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 11 Sep 2014 21:07:19 -0400 Subject: [PATCH 04/87] Debugging for strange Zotero.getString() error --- chrome/content/zotero/xpcom/zotero.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index 9065168b2..591f524e5 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -1444,6 +1444,8 @@ Components.utils.import("resource://gre/modules/Services.jsm"); } } catch (e){ + Components.utils.reportError(e); + Zotero.debug(e, 1); throw ('Localized string not available for ' + name); } return l10n; From f33d249e9cd2b4e822533e35d6ffacb120a4e736 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 11 Sep 2014 21:10:03 -0400 Subject: [PATCH 05/87] Update minVersion/maxVersion --- install.rdf | 4 ++-- update.rdf | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/install.rdf b/install.rdf index f024e2d0b..bbd467958 100644 --- a/install.rdf +++ b/install.rdf @@ -24,8 +24,8 @@ {ec8030f7-c20a-464f-9b0e-13a3a9e97384} - 17.0 - 30.* + 24.0 + 32.* diff --git a/update.rdf b/update.rdf index 9976ca5fd..6752721a2 100644 --- a/update.rdf +++ b/update.rdf @@ -11,8 +11,8 @@ {ec8030f7-c20a-464f-9b0e-13a3a9e97384} - 17.0 - 30.* + 24.0 + 32.* http://download.zotero.org/extension/zotero.xpi sha1: From 4464e8ed9ed026813aa8048ee28818589b4a0ef8 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 16 Sep 2014 15:46:13 -0400 Subject: [PATCH 06/87] Additional debugging for formatStringFromName error --- chrome/content/zotero/xpcom/zotero.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index 591f524e5..da8c65f7d 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -1444,6 +1444,9 @@ Components.utils.import("resource://gre/modules/Services.jsm"); } } catch (e){ + if (e.name == 'NS_ERROR_ILLEGAL_VALUE') { + Zotero.debug(params, 1); + } Components.utils.reportError(e); Zotero.debug(e, 1); throw ('Localized string not available for ' + name); From f5b5617885bba1c4a76e812853f3f6a0fe92c434 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 18 Sep 2014 16:23:49 -0400 Subject: [PATCH 07/87] Improve long-filename handling during syncing This will hopefully fix some remaining issues with long filenames during syncing, particularly on Linux with encrypted filenames (which have a filename length of 143). (This may have reintroduced some edge case bugs, so it needs some testing.) --- chrome/content/zotero/xpcom/file.js | 110 ++++++++- chrome/content/zotero/xpcom/storage.js | 225 +++++------------- .../zotero/xpcom/utilities_internal.js | 17 ++ 3 files changed, 185 insertions(+), 167 deletions(-) diff --git a/chrome/content/zotero/xpcom/file.js b/chrome/content/zotero/xpcom/file.js index 3797b28a6..7d82e5e30 100644 --- a/chrome/content/zotero/xpcom/file.js +++ b/chrome/content/zotero/xpcom/file.js @@ -311,6 +311,111 @@ Zotero.File = new function(){ } + this.createShortened = function (file, type, mode, maxBytes) { + if (!maxBytes) { + maxBytes = 255; + } + + // Limit should be 255, but leave room for unique numbering if necessary + var padding = 3; + + while (true) { + var newLength = maxBytes - padding; + + try { + file.create(type, mode); + } + catch (e) { + let pathError = false; + + let pathByteLength = Zotero.Utilities.Internal.byteLength(file.path); + let fileNameByteLength = Zotero.Utilities.Internal.byteLength(file.leafName); + + // Windows API only allows paths of 260 characters + if (e.name == "NS_ERROR_FILE_NOT_FOUND" && pathByteLength > 260) { + Zotero.debug("Path is " + file.path); + pathError = true; + } + // ext3/ext4/HFS+ have a filename length limit of ~254 bytes + else if ((e.name == "NS_ERROR_FAILURE" || e.name == "NS_ERROR_FILE_NAME_TOO_LONG") + && (fileNameByteLength >= 254 || (Zotero.isLinux && fileNameByteLength > 143))) { + Zotero.debug("Filename is '" + file.leafName + "'"); + } + else { + Zotero.debug("Path is " + file.path); + throw e; + } + + // Preserve extension + var matches = file.leafName.match(/\.[a-z0-9]{0,20}$/); + var ext = matches ? matches[0] : ""; + + if (pathError) { + let pathLength = pathByteLength - fileNameByteLength; + newLength -= pathLength; + + if (newLength < 5) { + throw new Error("Path is too long"); + } + } + + // Shorten the filename + // + // Shortened file could already exist if there was another file with a + // similar name that was also longer than the limit, so we do this in a + // loop, adding numbers if necessary + var uniqueFile = file.clone(); + var step = 0; + while (step < 100) { + let newBaseName = uniqueFile.leafName.substr(0, newLength - ext.length); + if (step == 0) { + var newName = newBaseName + ext; + } + else { + var newName = newBaseName + "-" + step + ext; + } + + // Check actual byte length, and shorten more if necessary + if (Zotero.Utilities.Internal.byteLength(newName) > maxBytes) { + step = 0; + newLength--; + continue; + } + + uniqueFile.leafName = newName; + if (!uniqueFile.exists()) { + break; + } + + step++; + } + + var msg = "Shortening filename to '" + newName + "'"; + Zotero.debug(msg, 2); + Zotero.log(msg, 'warning'); + + try { + uniqueFile.create(Components.interfaces.nsIFile.type, mode); + } + catch (e) { + // On Linux, try 143, which is the max filename length with eCryptfs + if (e.name == "NS_ERROR_FILE_NAME_TOO_LONG" && Zotero.isLinux && uniqueFile.leafName.length > 143) { + Zotero.debug("Trying shorter filename in case of filesystem encryption", 2); + maxBytes = 143; + continue; + } + else { + throw e; + } + } + + file.leafName = uniqueFile.leafName; + } + break; + } + } + + this.copyToUnique = function (file, newFile) { newFile.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0644); var newName = newFile.leafName; @@ -546,10 +651,13 @@ Zotero.File = new function(){ var opWord = Zotero.getString('file.accessError.updated'); } + Zotero.debug(file.path); + Zotero.debug(e, 1); + Components.utils.reportError(e); + if (e.name == 'NS_ERROR_FILE_ACCESS_DENIED' || e.name == 'NS_ERROR_FILE_IS_LOCKED' // These show up on some Windows systems || e.name == 'NS_ERROR_FAILURE' || e.name == 'NS_ERROR_FILE_NOT_FOUND') { - Zotero.debug(e); str = str + " " + Zotero.getString('file.accessError.cannotBe') + " " + opWord + "."; var checkFileWindows = Zotero.getString('file.accessError.message.windows'); var checkFileOther = Zotero.getString('file.accessError.message.other'); diff --git a/chrome/content/zotero/xpcom/storage.js b/chrome/content/zotero/xpcom/storage.js index 01ee860c9..fc4ea383c 100644 --- a/chrome/content/zotero/xpcom/storage.js +++ b/chrome/content/zotero/xpcom/storage.js @@ -1232,7 +1232,7 @@ Zotero.Sync.Storage = new function () { // If library isn't editable but filename was changed, update // database without updating the item's mod time, which would result // in a library access error - if (!Zotero.Items.editCheck(item)) { + if (!Zotero.Items.isEditable(item)) { Zotero.debug("File renamed without library access -- " + "updating itemAttachments path", 3); item.relinkAttachmentFile(newFile, true); @@ -1501,80 +1501,50 @@ Zotero.Sync.Storage = new function () { Zotero.debug("Moving download file " + tempFile.leafName + " into attachment directory as '" + fileName + "'"); try { - tempFile.moveTo(parentDir, fileName); + var destFile = parentDir.clone(); + destFile.append(fileName); + Zotero.File.createShortened(destFile, Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0644); } catch (e) { - var destFile = file.clone(); + Zotero.File.checkFileAccessError(e, destFile, 'create'); + } + + if (destFile.leafName != fileName) { + Zotero.debug("Changed filename '" + fileName + "' to '" + destFile.leafName + "'"); - var windowsLength = false; - var nameLength = false; - - // Windows API only allows paths of 260 characters - if (e.name == "NS_ERROR_FILE_NOT_FOUND" && destFile.path.length > 255) { - windowsLength = true; - } - // ext3/ext4/HFS+ have a filename length limit of ~254 bytes - // - // These filenames will almost always be ASCII ad files, - // but allow an extra 10 bytes anyway - else if (e.name == "NS_ERROR_FAILURE" && destFile.leafName.length >= 244) { - nameLength = true; - } - // Filesystem encryption (or, more specifically, filename encryption) - // can result in a lower limit -- not much we can do about this, - // but log a warning and skip the file - else if (e.name == "NS_ERROR_FAILURE" && Zotero.isLinux && destFile.leafName.length > 130) { - Zotero.debug(e); - var msg = Zotero.getString('sync.storage.error.encryptedFilenames', destFile.leafName); - Components.utils.reportError(msg); - return; - } - - if (windowsLength || nameLength) { - // Preserve extension - var matches = destFile.leafName.match(/\.[a-z0-9]{0,8}$/); - var ext = matches ? matches[0] : ""; - - if (windowsLength) { - var pathLength = destFile.path.length - destFile.leafName.length; - var newLength = 255 - pathLength; - // Require 40 available characters in path -- this is arbitrary, - // but otherwise filenames are going to end up being cut off - if (newLength < 40) { - var msg = "Due to a Windows path length limitation, your Zotero data directory " - + "is too deep in the filesystem for syncing to work reliably. " - + "Please relocate your Zotero data to a higher directory."; - throw (msg); - } + // Abort if Windows path limitation would cause filenames to be overly truncated + if (Zotero.isWin && destFile.leafName.length < 40) { + try { + destFile.remove(false); } - else { - var newLength = 254; - } - - // Shorten file if it's too long -- we don't relink it, but this should - // be pretty rare and probably only occurs on extraneous files with - // gibberish for filenames - var fileName = destFile.leafName.substr(0, newLength - (ext.length + 1)) + ext; - var msg = "Shortening filename to '" + fileName + "'"; - Zotero.debug(msg, 2); - Components.utils.reportError(msg); - - tempFile.moveTo(parentDir, fileName); - renamed = true; + catch (e) {} + var msg = "Due to a Windows path length limitation, your Zotero data directory " + + "is too deep in the filesystem for syncing to work reliably. " + + "Please relocate your Zotero data to a higher directory."; + Zotero.debug(msg, 1); + throw new Error(msg); } - else { - Components.utils.reportError(e); - var msg = Zotero.getString('sync.storage.error.fileNotCreated', parentDir.leafName + '/' + fileName); - throw(msg); + + renamed = true; + } + + try { + tempFile.moveTo(parentDir, destFile.leafName); + } + catch (e) { + try { + destFile.remove(false); } + catch (e) {} + + Zotero.File.checkFileAccessError(e, destFile, 'create'); } var returnFile = null; // processDownload() needs to know that we're renaming the file if (renamed) { - var returnFile = file.clone(); + var returnFile = destFile.clone(); } - return returnFile; } @@ -1704,124 +1674,47 @@ Zotero.Sync.Storage = new function () { } try { - destFile.create(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0644); + Zotero.File.createShortened(destFile, Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0644); } catch (e) { Zotero.debug(e, 1); + Components.utils.reportError(e); - var windowsLength = false; - var nameLength = false; + zipReader.close(); - // Windows API only allows paths of 260 characters - if (e.name == "NS_ERROR_FILE_NOT_FOUND" && destFile.path.length > 255) { - Zotero.debug("Path is " + destFile.path); - windowsLength = true; - } - // ext3/ext4/HFS+ have a filename length limit of ~254 bytes - // - // These filenames will almost always be ASCII ad files, - // but allow an extra 10 bytes anyway - else if (e.name == "NS_ERROR_FAILURE" && destFile.leafName.length >= 244) { - Zotero.debug("Filename is " + destFile.leafName); - nameLength = true; - } - // Filesystem encryption (or, more specifically, filename encryption) - // can result in a lower limit -- not much we can do about this, - // but log a warning and skip the file - else if (e.name == "NS_ERROR_FAILURE" && Zotero.isLinux && destFile.leafName.length > 130) { - var msg = Zotero.getString('sync.storage.error.encryptedFilenames', destFile.leafName); - Components.utils.reportError(msg); - continue; - } - else { - Zotero.debug("Path is " + destFile.path); - } + Zotero.File.checkFileAccessError(e, destFile, 'create'); + } + + if (destFile.leafName != fileName) { + Zotero.debug("Changed filename '" + fileName + "' to '" + destFile.leafName + "'"); - if (windowsLength || nameLength) { - // Preserve extension - var matches = destFile.leafName.match(/\.[a-z0-9]{0,8}$/); - var ext = matches ? matches[0] : ""; - - if (windowsLength) { - var pathLength = destFile.path.length - destFile.leafName.length; - // Limit should be 255, but a shorter limit seems to be - // enforced for nsIZipReader.extract() below on - // non-English systems - var newLength = 240 - pathLength; - // Require 40 available characters in path -- this is arbitrary, - // but otherwise filenames are going to end up being cut off - if (newLength < 40) { - zipReader.close(); - var msg = "Due to a Windows path length limitation, your Zotero data directory " - + "is too deep in the filesystem for syncing to work reliably. " - + "Please relocate your Zotero data to a higher directory."; - throw (msg); - } - } - else { - var newLength = 240; - } - - // Shorten file if it's too long -- we don't relink it, but this should - // be pretty rare and probably only occurs on extraneous files with - // gibberish for filenames - // - // Shortened file could already exist if there was another file with a - // similar name that was also longer than the limit, so we do this in a - // loop, adding numbers if necessary - var step = 0; - do { - if (step == 0) { - var newName = destFile.leafName.substr(0, newLength - ext.length) + ext; - } - else { - var newName = destFile.leafName.substr(0, newLength - ext.length) + "-" + step + ext; - } - destFile.leafName = newName; - step++; - } - while (destFile.exists()); - - var msg = "Shortening filename to '" + newName + "'"; - Zotero.debug(msg, 2); - Components.utils.reportError(msg); - + // Abort if Windows path limitation would cause filenames to be overly truncated + if (Zotero.isWin && destFile.leafName.length < 40) { try { - destFile.create(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0644); + destFile.remove(false); } - catch (e) { - // See above - if (e.name == "NS_ERROR_FAILURE" && Zotero.isLinux && destFile.leafName.length > 130) { - Zotero.debug(e); - var msg = Zotero.getString('sync.storage.error.encryptedFilenames', destFile.leafName); - Components.utils.reportError(msg); - continue; - } - - zipReader.close(); - - Components.utils.reportError(e); - var msg = Zotero.getString('sync.storage.error.fileNotCreated', parentDir.leafName + '/' + fileName); - throw(msg); - } - - if (primaryFile) { - renamed = true; - } - } - else { + catch (e) {} zipReader.close(); - - Components.utils.reportError(e); - var msg = Zotero.getString('sync.storage.error.fileNotCreated', parentDir.leafName + '/' + fileName); - throw(msg); + var msg = "Due to a Windows path length limitation, your Zotero data directory " + + "is too deep in the filesystem for syncing to work reliably. " + + "Please relocate your Zotero data to a higher directory."; + Zotero.debug(msg, 1); + throw new Error(msg); + } + + if (primaryFile) { + renamed = true; } } + try { zipReader.extract(entryName, destFile); } catch (e) { - Zotero.debug(destFile.path); + try { + destFile.remove(false); + } + catch (e) {} // For advertising junk files, ignore a bug on Windows where // destFile.create() works but zipReader.extract() doesn't diff --git a/chrome/content/zotero/xpcom/utilities_internal.js b/chrome/content/zotero/xpcom/utilities_internal.js index 0d699639e..d7d2e5f83 100644 --- a/chrome/content/zotero/xpcom/utilities_internal.js +++ b/chrome/content/zotero/xpcom/utilities_internal.js @@ -194,6 +194,23 @@ Zotero.Utilities.Internal = { }, + /** + * Return the byte length of a UTF-8 string + * + * http://stackoverflow.com/a/23329386 + */ + byteLength: function (str) { + var s = str.length; + for (var i=str.length-1; i>=0; i--) { + var code = str.charCodeAt(i); + if (code > 0x7f && code <= 0x7ff) s++; + else if (code > 0x7ff && code <= 0xffff) s+=2; + if (code >= 0xDC00 && code <= 0xDFFF) i--; //trail surrogate + } + return s; + }, + + /** * Display a prompt from an error with custom buttons and a callback */ From 5a8de7054cec894000f377b40698f9d09cd7629a Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 18 Sep 2014 16:54:05 -0400 Subject: [PATCH 08/87] Ignore case when extracting extension in Zotero.File.createShortened() --- chrome/content/zotero/xpcom/file.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/file.js b/chrome/content/zotero/xpcom/file.js index 7d82e5e30..bb05035ff 100644 --- a/chrome/content/zotero/xpcom/file.js +++ b/chrome/content/zotero/xpcom/file.js @@ -347,7 +347,7 @@ Zotero.File = new function(){ } // Preserve extension - var matches = file.leafName.match(/\.[a-z0-9]{0,20}$/); + var matches = file.leafName.match(/\.[a-z0-9]{0,20}$/i); var ext = matches ? matches[0] : ""; if (pathError) { From 2a986c8635f3f368ba493b5b9c041cc572ccc0b1 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 18 Sep 2014 17:23:57 -0400 Subject: [PATCH 09/87] Don't match extension in createShortened() for dot-files (.hidden) --- chrome/content/zotero/xpcom/file.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/file.js b/chrome/content/zotero/xpcom/file.js index bb05035ff..0822914d1 100644 --- a/chrome/content/zotero/xpcom/file.js +++ b/chrome/content/zotero/xpcom/file.js @@ -347,8 +347,8 @@ Zotero.File = new function(){ } // Preserve extension - var matches = file.leafName.match(/\.[a-z0-9]{0,20}$/i); - var ext = matches ? matches[0] : ""; + var matches = file.leafName.match(/.+(\.[a-z0-9]{0,20})$/i); + var ext = matches ? matches[1] : ""; if (pathError) { let pathLength = pathByteLength - fileNameByteLength; From 48955c898379ddff1380435e69b181d2c93622c7 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 18 Sep 2014 17:32:45 -0400 Subject: [PATCH 10/87] Check ext length explicitly in createShortened when checking path length --- chrome/content/zotero/xpcom/file.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/file.js b/chrome/content/zotero/xpcom/file.js index 0822914d1..e6467c7ee 100644 --- a/chrome/content/zotero/xpcom/file.js +++ b/chrome/content/zotero/xpcom/file.js @@ -354,7 +354,8 @@ Zotero.File = new function(){ let pathLength = pathByteLength - fileNameByteLength; newLength -= pathLength; - if (newLength < 5) { + // Make sure there's a least 1 character of the basename left over + if (newLength - ext.length < 1) { throw new Error("Path is too long"); } } From 57ec10dfd4a96aeefe41b88b3a62c7766096fb38 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 18 Sep 2014 17:35:25 -0400 Subject: [PATCH 11/87] Remove unnecessary var --- chrome/content/zotero/xpcom/storage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/storage.js b/chrome/content/zotero/xpcom/storage.js index fc4ea383c..fe483812e 100644 --- a/chrome/content/zotero/xpcom/storage.js +++ b/chrome/content/zotero/xpcom/storage.js @@ -1543,7 +1543,7 @@ Zotero.Sync.Storage = new function () { var returnFile = null; // processDownload() needs to know that we're renaming the file if (renamed) { - var returnFile = destFile.clone(); + returnFile = destFile.clone(); } return returnFile; } From fd31e41e2f176f21b9ff4ee95d6881c33aea70b3 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 18 Sep 2014 17:41:46 -0400 Subject: [PATCH 12/87] Add localization todos --- chrome/content/zotero/xpcom/storage.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/chrome/content/zotero/xpcom/storage.js b/chrome/content/zotero/xpcom/storage.js index fe483812e..24a6a4c18 100644 --- a/chrome/content/zotero/xpcom/storage.js +++ b/chrome/content/zotero/xpcom/storage.js @@ -1518,6 +1518,7 @@ Zotero.Sync.Storage = new function () { destFile.remove(false); } catch (e) {} + // TODO: localize var msg = "Due to a Windows path length limitation, your Zotero data directory " + "is too deep in the filesystem for syncing to work reliably. " + "Please relocate your Zotero data to a higher directory."; @@ -1695,6 +1696,7 @@ Zotero.Sync.Storage = new function () { } catch (e) {} zipReader.close(); + // TODO: localize var msg = "Due to a Windows path length limitation, your Zotero data directory " + "is too deep in the filesystem for syncing to work reliably. " + "Please relocate your Zotero data to a higher directory."; From ce6cba7974da3cf53c9be97dc571eeeb56364e43 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 19 Sep 2014 15:52:53 -0400 Subject: [PATCH 13/87] Don't log stack trace for getString() failure unless unexpected --- chrome/content/zotero/xpcom/search.js | 1 + chrome/content/zotero/xpcom/zotero.js | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/search.js b/chrome/content/zotero/xpcom/search.js index a351ed73c..fde3ab0dd 100644 --- a/chrome/content/zotero/xpcom/search.js +++ b/chrome/content/zotero/xpcom/search.js @@ -2383,6 +2383,7 @@ Zotero.SearchConditions = new function(){ return Zotero.getString('searchConditions.' + str) } catch (e) { + Zotero.debug("String not found for searchConditions." + str, 2); return Zotero.ItemFields.getLocalizedString(null, str); } } diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index da8c65f7d..7d6f652a7 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -1447,8 +1447,10 @@ Components.utils.import("resource://gre/modules/Services.jsm"); if (e.name == 'NS_ERROR_ILLEGAL_VALUE') { Zotero.debug(params, 1); } - Components.utils.reportError(e); - Zotero.debug(e, 1); + else if (e.name != 'NS_ERROR_FAILURE') { + Components.utils.reportError(e); + Zotero.debug(e, 1); + } throw ('Localized string not available for ' + name); } return l10n; From 10ba5e31d648dcdf9b07a6bfe95a7cf810a610ac Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 19 Sep 2014 20:37:59 -0400 Subject: [PATCH 14/87] Fix error from letter items with more than 10 recipients https://forums.zotero.org/discussion/40218/ --- chrome/content/zotero/xpcom/data/item.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index 08a15a0c1..f24a83dcc 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -908,9 +908,9 @@ Zotero.Item.prototype.getDisplayTitle = function (includeAuthorAndDate) { } if (participants.length > 0) { - var names = []; - for each(participant in participants) { - names.push(participant.ref.lastName); + let names = []; + for (let i=0; i<4; i++) { + names.push(participants[i].ref.lastName); } switch (names.length) { case 1: From f09871a1ee7a3fee71ecc3261146798573f40bb1 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 19 Sep 2014 20:39:23 -0400 Subject: [PATCH 15/87] Convert additional for..in loops to for loops in getDisplayTitle() --- chrome/content/zotero/xpcom/data/item.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index f24a83dcc..3eaeca987 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -877,11 +877,12 @@ Zotero.Item.prototype.getDisplayTitle = function (includeAuthorAndDate) { var itemTypeName = Zotero.ItemTypes.getName(itemTypeID); if (!title && (itemTypeID == 8 || itemTypeID == 10)) { // 'letter' and 'interview' itemTypeIDs - var creators = this.getCreators(); - var authors = []; - var participants = []; + let creators = this.getCreators(); + let authors = []; + let participants = []; if (creators) { - for each(var creator in creators) { + for (let i=0; i Date: Fri, 19 Sep 2014 20:42:29 -0400 Subject: [PATCH 16/87] Update versions --- install.rdf | 2 +- update.rdf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/install.rdf b/install.rdf index bbd467958..46b19c31c 100644 --- a/install.rdf +++ b/install.rdf @@ -6,7 +6,7 @@ zotero@chnm.gmu.edu Zotero - 4.0.22.SOURCE + 4.0.23.SOURCE Center for History and New Media
George Mason University
Dan Cohen Sean Takats diff --git a/update.rdf b/update.rdf index 6752721a2..0258aeb4c 100644 --- a/update.rdf +++ b/update.rdf @@ -7,7 +7,7 @@ - 4.0.22.SOURCE + 4.0.23.SOURCE {ec8030f7-c20a-464f-9b0e-13a3a9e97384} From b0550273ae1bedba67e6d37627d0e5ea2d4b296e Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 19 Sep 2014 20:43:50 -0400 Subject: [PATCH 17/87] Update another version --- chrome/content/zotero/xpcom/zotero.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index 7d6f652a7..0e4a247c3 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -39,7 +39,7 @@ const ZOTERO_CONFIG = { BOOKMARKLET_ORIGIN : 'https://www.zotero.org', HTTP_BOOKMARKLET_ORIGIN : 'http://www.zotero.org', BOOKMARKLET_URL: 'https://www.zotero.org/bookmarklet/', - VERSION: "4.0.22.SOURCE" + VERSION: "4.0.23.SOURCE" }; // Commonly used imports accessible anywhere From cb707a55c8f8abc7d5cc9dd6cc23eba21bbb0308 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sat, 20 Sep 2014 16:33:53 -0400 Subject: [PATCH 18/87] Fix breakage from 10ba5e31d --- chrome/content/zotero/xpcom/data/item.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index 3eaeca987..8dae49950 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -910,7 +910,8 @@ Zotero.Item.prototype.getDisplayTitle = function (includeAuthorAndDate) { if (participants.length > 0) { let names = []; - for (let i=0; i<4; i++) { + let max = Math.min(4, participants.length); + for (let i=0; i Date: Fri, 3 Oct 2014 16:05:14 -0400 Subject: [PATCH 19/87] Log state check errors (and other logError calls) to debug output --- chrome/content/zotero/xpcom/zotero.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index 0e4a247c3..f41162958 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -1312,10 +1312,11 @@ Components.utils.import("resource://gre/modules/Services.jsm"); } /** - * Log a JS error to the Mozilla JS error console. + * Log a JS error to Mozilla JS error console and debug output * @param {Exception} err */ function logError(err) { + Zotero.debug(log, 1); log(err.message ? err.message : err.toString(), "error", err.fileName ? err.fileName : (err.filename ? err.filename : null), null, err.lineNumber ? err.lineNumber : null, null); From 72bb8acfd15f13427e9aaebf4b36487e08a1b76d Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 3 Oct 2014 16:06:01 -0400 Subject: [PATCH 20/87] Fix previous commit --- chrome/content/zotero/xpcom/zotero.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index f41162958..f1c38d93e 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -1316,7 +1316,7 @@ Components.utils.import("resource://gre/modules/Services.jsm"); * @param {Exception} err */ function logError(err) { - Zotero.debug(log, 1); + Zotero.debug(err, 1); log(err.message ? err.message : err.toString(), "error", err.fileName ? err.fileName : (err.filename ? err.filename : null), null, err.lineNumber ? err.lineNumber : null, null); From 71bd1a7f99cd14152486ffd1bdcccece4522d8cd Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sun, 5 Oct 2014 12:03:50 -0400 Subject: [PATCH 21/87] Fix state check errors (middle-pane restart messages) during syncing The state check errors were caused by 4812ab6f, which was a fix for "Q.async(...)(...) is undefined" errors caused by ad8b81f4c, which was a fix for "too much recursion" errors related to Task.spawn() on Windows with JIT enabled. --- chrome/content/zotero/xpcom/sync.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/chrome/content/zotero/xpcom/sync.js b/chrome/content/zotero/xpcom/sync.js index 185ef41ed..9ed9e9fca 100644 --- a/chrome/content/zotero/xpcom/sync.js +++ b/chrome/content/zotero/xpcom/sync.js @@ -1627,7 +1627,7 @@ Zotero.Sync.Server = new function () { _error(e); } - Q.async(Zotero.Sync.Server.Data.processUpdatedXML( + var result = Q.async(Zotero.Sync.Server.Data.processUpdatedXML( responseNode.getElementsByTagName('updated')[0], lastLocalSyncDate, syncSession, @@ -1836,13 +1836,11 @@ Zotero.Sync.Server = new function () { Zotero.HTTP.doPost(url, body, uploadCallback); } } - ))() - .then( - null, - function (e) { - errorHandler(e); - } - ); + ))(); + + if (Q.isPromise(result)) { + result.catch(errorHandler); + } } catch (e) { _error(e); @@ -2676,8 +2674,6 @@ Zotero.Sync.Server.Data = new function() { this.processUpdatedXML = function (updatedNode, lastLocalSyncDate, syncSession, defaultLibraryID, callback) { - yield true; - updatedNode.xpath = function (path) { return Zotero.Utilities.xpath(this, path); }; From 497939bb28c3ada9cc70de20e6ce234bd34cd387 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 8 Oct 2014 13:04:56 -0400 Subject: [PATCH 22/87] Fix "Open Account Settings" button in quota dialog in Standalone (Untested, but this should work.) --- chrome/content/zotero/xpcom/storage/zfs.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/storage/zfs.js b/chrome/content/zotero/xpcom/storage/zfs.js index 7e3880d50..c1f44ad54 100644 --- a/chrome/content/zotero/xpcom/storage/zfs.js +++ b/chrome/content/zotero/xpcom/storage/zfs.js @@ -310,8 +310,7 @@ Zotero.Sync.Storage.ZFS = (function () { var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] .getService(Components.interfaces.nsIWindowMediator); var win = wm.getMostRecentWindow("navigator:browser"); - var browser = win.getBrowser(); - browser.selectedTab = browser.addTab(url); + win.ZoteroPane.loadURI(url); } } From eba296a45f845704554a231015704edfd3a5ec59 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 8 Oct 2014 13:11:30 -0400 Subject: [PATCH 23/87] Closes #554, Sync settings pane should point to new TOS --- chrome/content/zotero/preferences/preferences_sync.xul | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chrome/content/zotero/preferences/preferences_sync.xul b/chrome/content/zotero/preferences/preferences_sync.xul index ccc080d3b..9d8e28b11 100644 --- a/chrome/content/zotero/preferences/preferences_sync.xul +++ b/chrome/content/zotero/preferences/preferences_sync.xul @@ -240,7 +240,7 @@ - From e34c0db060ecd79117ffe5bd218a3250c5fe5bb5 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 8 Oct 2014 13:49:41 -0400 Subject: [PATCH 24/87] Make 'https' the default in WebDAV prefs drop-down --- chrome/content/zotero/preferences/preferences_sync.xul | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chrome/content/zotero/preferences/preferences_sync.xul b/chrome/content/zotero/preferences/preferences_sync.xul index 9d8e28b11..928757764 100644 --- a/chrome/content/zotero/preferences/preferences_sync.xul +++ b/chrome/content/zotero/preferences/preferences_sync.xul @@ -148,8 +148,8 @@ onsynctopreference="Zotero_Preferences.Sync.unverifyStorageServer()" style="padding: 0; width: 7em"> - +