From 71db21c6051635b47687072d99b88a4839c919ab Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Wed, 12 Sep 2012 14:25:46 -0400 Subject: [PATCH 01/14] Fix nonbreaking spaces in citations edited using classic add citation dialog --- chrome/content/zotero/bindings/styled-textbox.xml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/chrome/content/zotero/bindings/styled-textbox.xml b/chrome/content/zotero/bindings/styled-textbox.xml index 585d52ca79..041f5a65ca 100644 --- a/chrome/content/zotero/bindings/styled-textbox.xml +++ b/chrome/content/zotero/bindings/styled-textbox.xml @@ -231,10 +231,9 @@ output = output.replace(entry[0], entry[1], "g"); } - output = Zotero.Utilities.unescapeHTML( - output.replace(" ", " ", "g")) - .replace(highcharRe, - function(aChar) { return "\\uc0\\u"+aChar.charCodeAt(0).toString()+"{}" }); + output = Zotero.Utilities.unescapeHTML(output.replace(" ", " ", "g")) + .replace("\u00A0", " ", "g") + .replace(highcharRe, function(aChar) { return "\\uc0\\u"+aChar.charCodeAt(0).toString()+"{}" }); output = Zotero.Utilities.trim(output); } From 53449d47a993f615000490938ccbd1fa24ad6715 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 13 Sep 2012 14:42:15 -0400 Subject: [PATCH 02/14] Install styles served as application/vnd.citationstyles.style+xml --- chrome/content/zotero/xpcom/mimeTypeHandler.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/mimeTypeHandler.js b/chrome/content/zotero/xpcom/mimeTypeHandler.js index 9a7af70348..e1f590d9be 100644 --- a/chrome/content/zotero/xpcom/mimeTypeHandler.js +++ b/chrome/content/zotero/xpcom/mimeTypeHandler.js @@ -70,7 +70,8 @@ Zotero.MIMETypeHandler = new function () { // Not even trying this.addHandler("ris", _importHandler, true); } - this.addHandler("text/x-csl", function(a1, a2) { Zotero.Styles.install(a1, a2) }); + this.addHandler("application/vnd.citationstyles.style+xml", function(a1, a2) { Zotero.Styles.install(a1, a2) }); + this.addHandler("text/x-csl", function(a1, a2) { Zotero.Styles.install(a1, a2) }); // deprecated this.addHandler("application/x-zotero-schema", Zotero.Schema.importSchema); this.addHandler("application/x-zotero-settings", Zotero.Prefs.importSettings); } From d6bd35300506c5ae7a344d27950f2726e7c752ef Mon Sep 17 00:00:00 2001 From: aurimasv Date: Thu, 13 Sep 2012 22:51:08 -0500 Subject: [PATCH 03/14] Allow relative file attachment import. Fix some bugs in _parsePath. --- .../content/zotero/xpcom/translation/translate_item.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/chrome/content/zotero/xpcom/translation/translate_item.js b/chrome/content/zotero/xpcom/translation/translate_item.js index b7340099d4..0b79313b9d 100644 --- a/chrome/content/zotero/xpcom/translation/translate_item.js +++ b/chrome/content/zotero/xpcom/translation/translate_item.js @@ -204,7 +204,7 @@ Zotero.Translate.ItemSaver.prototype = { }, "_saveAttachmentFile":function(attachment, parentID) { - const urlRe = /(([A-Za-z]+):\/\/[^\s]*)/i; + const urlRe = /(([a-z]+):\/\/[^\s]*)/i; Zotero.debug("Translate: Adding attachment", 4); if(!attachment.url && !attachment.path) { @@ -216,7 +216,7 @@ Zotero.Translate.ItemSaver.prototype = { // see if this is actually a file URL var m = urlRe.exec(attachment.url); var protocol = m ? m[2].toLowerCase() : ""; - if(protocol == "file") { + if(protocol == "file" || protocol == "") { attachment.path = attachment.url; attachment.url = false; } else if(protocol != "http" && protocol != "https") { @@ -275,7 +275,7 @@ Zotero.Translate.ItemSaver.prototype = { var uri = IOService.newURI(path, "", this._baseURI); } catch (e) { - var msg = "Error parsing attachment path: " + attachment.path; + var msg = "Error parsing attachment path: " + path; Zotero.logError(msg); Zotero.debug("Translate: " + msg, 2); return false; @@ -284,14 +284,14 @@ Zotero.Translate.ItemSaver.prototype = { try { var file = uri.QueryInterface(Components.interfaces.nsIFileURL).file; if (file.path == '/') { - var msg = "Error parsing attachment path: " + attachment.path; + var msg = "Error parsing attachment path: " + path; Zotero.logError(msg); Zotero.debug("Translate: " + msg, 2); return false; } } catch (e) { - var msg = "Error getting file from attachment path: " + attachment.path; + var msg = "Error getting file from attachment path: " + path; Zotero.logError(msg); Zotero.debug("Translate: " + msg, 2); return false; From b94837d3da334b273536099425dd852d7b59a7d3 Mon Sep 17 00:00:00 2001 From: aurimasv Date: Fri, 14 Sep 2012 02:21:54 -0500 Subject: [PATCH 04/14] Recognize URI protocol based on RFC 3986 specification --- chrome/content/zotero/xpcom/translation/translate_item.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/translation/translate_item.js b/chrome/content/zotero/xpcom/translation/translate_item.js index 0b79313b9d..777d93f28a 100644 --- a/chrome/content/zotero/xpcom/translation/translate_item.js +++ b/chrome/content/zotero/xpcom/translation/translate_item.js @@ -204,7 +204,7 @@ Zotero.Translate.ItemSaver.prototype = { }, "_saveAttachmentFile":function(attachment, parentID) { - const urlRe = /(([a-z]+):\/\/[^\s]*)/i; + const urlRe = /(([a-z][-+\.a-z0-9]*):\/\/[^\s]*)/i; //according to RFC3986 Zotero.debug("Translate: Adding attachment", 4); if(!attachment.url && !attachment.path) { From cffbed31e837af6dcc85234f715410e1b44a87bf Mon Sep 17 00:00:00 2001 From: aurimasv Date: Fri, 14 Sep 2012 20:09:58 -0500 Subject: [PATCH 05/14] Make protocol decision clearer --- chrome/content/zotero/xpcom/translation/translate_item.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/translation/translate_item.js b/chrome/content/zotero/xpcom/translation/translate_item.js index 777d93f28a..64e5e60896 100644 --- a/chrome/content/zotero/xpcom/translation/translate_item.js +++ b/chrome/content/zotero/xpcom/translation/translate_item.js @@ -215,8 +215,8 @@ Zotero.Translate.ItemSaver.prototype = { if(!attachment.path) { // see if this is actually a file URL var m = urlRe.exec(attachment.url); - var protocol = m ? m[2].toLowerCase() : ""; - if(protocol == "file" || protocol == "") { + var protocol = m ? m[2].toLowerCase() : "file"; + if(protocol == "file") { attachment.path = attachment.url; attachment.url = false; } else if(protocol != "http" && protocol != "https") { From b700f3ef5605d5b53bada10474a80584dded0437 Mon Sep 17 00:00:00 2001 From: aurimasv Date: Mon, 17 Sep 2012 01:33:24 -0500 Subject: [PATCH 06/14] Fix typo in proxy detection. --- chrome/content/zotero/xpcom/connector/translator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/connector/translator.js b/chrome/content/zotero/xpcom/connector/translator.js index 1bba38f285..62adbf4476 100644 --- a/chrome/content/zotero/xpcom/connector/translator.js +++ b/chrome/content/zotero/xpcom/connector/translator.js @@ -160,7 +160,7 @@ Zotero.Translators = new function() { if(m) { // First, drop the 0- if it exists (this is an III invention) var host = m[2]; - if(host.substr(0, 2) === "0-") host = substr(2); + if(host.substr(0, 2) === "0-") host = host.substr(2); var hostnames = host.split("."); for(var i=1; i Date: Wed, 19 Sep 2012 02:37:18 -0400 Subject: [PATCH 07/14] Use ASCII for translator filenames Remove diacritics and then use translatorID for anything that still has extended characters. Fixes #459, Non-ascii translator names --- chrome/content/zotero/xpcom/schema.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/schema.js b/chrome/content/zotero/xpcom/schema.js index 868d757221..623ffe1018 100644 --- a/chrome/content/zotero/xpcom/schema.js +++ b/chrome/content/zotero/xpcom/schema.js @@ -692,7 +692,12 @@ Zotero.Schema = new function(){ } } - var fileName = Zotero.File.getValidFileName(entry.label) + fileExt; + var fileName = Zotero.Utilities.removeDiacritics( + Zotero.File.getValidFileName(entry.label)) + fileExt; + // Use translatorID if name still isn't ASCII (e.g., Cyrillic) + if (!fileName.match(/^[\x00-\x7f]+$/)) { + fileName = entry.translatorID + fileExt; + } var destFile = destDir.clone(); destFile.append(fileName); @@ -815,7 +820,12 @@ Zotero.Schema = new function(){ } if (mode == 'translator') { - var fileName = Zotero.File.getValidFileName(newObj[titleField]) + fileExt + var fileName = Zotero.Utilities.removeDiacritics( + Zotero.File.getValidFileName(newObj[titleField])) + fileExt; + // Use translatorID if name still isn't ASCII (e.g., Cyrillic) + if (!fileName.match(/^[\x00-\x7f]+$/)) { + fileName = newObj.translatorID + fileExt; + } } else if (mode == 'style') { var fileName = file.leafName; From 020eaf2d470af493000daa2c71d26cd5d822ac01 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 19 Sep 2012 03:37:44 -0400 Subject: [PATCH 08/14] Fix translatorID in filename in ZIP build, hopefully Follow-up from d821778 Refs #459, Non-ascii translator names --- chrome/content/zotero/xpcom/schema.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/schema.js b/chrome/content/zotero/xpcom/schema.js index 623ffe1018..64ebf93dff 100644 --- a/chrome/content/zotero/xpcom/schema.js +++ b/chrome/content/zotero/xpcom/schema.js @@ -696,7 +696,7 @@ Zotero.Schema = new function(){ Zotero.File.getValidFileName(entry.label)) + fileExt; // Use translatorID if name still isn't ASCII (e.g., Cyrillic) if (!fileName.match(/^[\x00-\x7f]+$/)) { - fileName = entry.translatorID + fileExt; + fileName = translatorID + fileExt; } var destFile = destDir.clone(); From dee75dd41732f8f88d7bb308cf527ed83ad5a846 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 19 Sep 2012 04:19:30 -0400 Subject: [PATCH 09/14] Save translator names as ASCII during repo updates as well Refs #459, Non-ascii translator names --- chrome/content/zotero/xpcom/schema.js | 18 ++++++------------ .../zotero/xpcom/translation/translator.js | 14 +++++++++++--- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/chrome/content/zotero/xpcom/schema.js b/chrome/content/zotero/xpcom/schema.js index 64ebf93dff..86fb3b6888 100644 --- a/chrome/content/zotero/xpcom/schema.js +++ b/chrome/content/zotero/xpcom/schema.js @@ -692,12 +692,9 @@ Zotero.Schema = new function(){ } } - var fileName = Zotero.Utilities.removeDiacritics( - Zotero.File.getValidFileName(entry.label)) + fileExt; - // Use translatorID if name still isn't ASCII (e.g., Cyrillic) - if (!fileName.match(/^[\x00-\x7f]+$/)) { - fileName = translatorID + fileExt; - } + var fileName = Zotero.Translators.getFileNameFromLabel( + entry.label, translatorID + ); var destFile = destDir.clone(); destFile.append(fileName); @@ -820,12 +817,9 @@ Zotero.Schema = new function(){ } if (mode == 'translator') { - var fileName = Zotero.Utilities.removeDiacritics( - Zotero.File.getValidFileName(newObj[titleField])) + fileExt; - // Use translatorID if name still isn't ASCII (e.g., Cyrillic) - if (!fileName.match(/^[\x00-\x7f]+$/)) { - fileName = newObj.translatorID + fileExt; - } + var fileName = Zotero.Translators.getFileNameFromLabel( + newObj[titleField], newObj.translatorID + ); } else if (mode == 'style') { var fileName = file.leafName; diff --git a/chrome/content/zotero/xpcom/translation/translator.js b/chrome/content/zotero/xpcom/translation/translator.js index cc933bc88d..5774358ac1 100644 --- a/chrome/content/zotero/xpcom/translation/translator.js +++ b/chrome/content/zotero/xpcom/translation/translator.js @@ -305,8 +305,14 @@ Zotero.Translators = new function() { * @param {String} label * @return {String} */ - this.getFileNameFromLabel = function(label) { - return Zotero.File.getValidFileName(label) + ".js"; + this.getFileNameFromLabel = function(label, alternative) { + var fileName = Zotero.Utilities.removeDiacritics( + Zotero.File.getValidFileName(label)) + ".js"; + // Use translatorID if name still isn't ASCII (e.g., Cyrillic) + if (alternative && !fileName.match(/^[\x00-\x7f]+$/)) { + fileName = alternative + ".js"; + } + return fileName; } /** @@ -361,7 +367,9 @@ Zotero.Translators = new function() { throw ("code not provided in Zotero.Translators.save()"); } - var fileName = Zotero.Translators.getFileNameFromLabel(metadata.label); + var fileName = Zotero.Translators.getFileNameFromLabel( + metadata.label, metadata.translatorID + ); var destFile = Zotero.getTranslatorsDirectory(); destFile.append(fileName); From a9cb1e75f5f26359597d5d6f7c204b41adaa338a Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 19 Sep 2012 15:02:47 -0400 Subject: [PATCH 10/14] Switch to master branch of CSL locales --- chrome/content/zotero/locale/csl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chrome/content/zotero/locale/csl b/chrome/content/zotero/locale/csl index 36d26a584a..2288e745e7 160000 --- a/chrome/content/zotero/locale/csl +++ b/chrome/content/zotero/locale/csl @@ -1 +1 @@ -Subproject commit 36d26a584ac869f2dfbdd528f57141a3bbcf016f +Subproject commit 2288e745e7c13cac7a78bb294d09cf19ad2cf23e From df6426af2e428784d0fb5600aa4e1b75fa15f6fd Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Fri, 21 Sep 2012 19:49:27 -0400 Subject: [PATCH 11/14] Fixes #168, Properly adjust index when skipping empty creators --- chrome/content/zotero/xpcom/translation/translate_item.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/translation/translate_item.js b/chrome/content/zotero/xpcom/translation/translate_item.js index b7340099d4..393f7531a7 100644 --- a/chrome/content/zotero/xpcom/translation/translate_item.js +++ b/chrome/content/zotero/xpcom/translation/translate_item.js @@ -401,6 +401,7 @@ Zotero.Translate.ItemSaver.prototype = { }, "_saveCreators":function(item, newItem) { + var creatorIndex = 0; for(var i=0; i Date: Wed, 26 Sep 2012 21:57:40 -0400 Subject: [PATCH 12/14] Fix "(null)" in Firefox login manager corruption message (It turns out this also displays if the user clicks Cancel on a master password prompt, though.) --- chrome/content/zotero/xpcom/sync.js | 2 +- chrome/locale/en-US/zotero/zotero.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/sync.js b/chrome/content/zotero/xpcom/sync.js index de594f232f..cff2afec98 100644 --- a/chrome/content/zotero/xpcom/sync.js +++ b/chrome/content/zotero/xpcom/sync.js @@ -1144,7 +1144,7 @@ Zotero.Sync.Server = new function () { catch (e) { Zotero.debug(e); var msg = Zotero.getString('sync.error.loginManagerCorrupted1', Zotero.appName) + "\n\n" - + Zotero.getString('sync.error.loginManagerCorrupted2', Zotero.appName); + + Zotero.getString('sync.error.loginManagerCorrupted2', [Zotero.appName, Zotero.appName]); alert(msg); return ''; } diff --git a/chrome/locale/en-US/zotero/zotero.properties b/chrome/locale/en-US/zotero/zotero.properties index 7034184cb4..0d454ef540 100644 --- a/chrome/locale/en-US/zotero/zotero.properties +++ b/chrome/locale/en-US/zotero/zotero.properties @@ -657,7 +657,7 @@ sync.error.passwordNotSet = Password not set sync.error.invalidLogin = Invalid username or password sync.error.enterPassword = Please enter a password. sync.error.loginManagerCorrupted1 = Zotero cannot access your login information, likely due to a corrupted %S login manager database. -sync.error.loginManagerCorrupted2 = Close %S, back up and delete signons.* from your %S profile, and re-enter your Zotero login information in the Sync pane of the Zotero preferences. +sync.error.loginManagerCorrupted2 = Close %1$S, back up and delete signons.* from your %2$S profile, and re-enter your Zotero login information in the Sync pane of the Zotero preferences. sync.error.syncInProgress = A sync operation is already in progress. sync.error.syncInProgress.wait = Wait for the previous sync to complete or restart %S. sync.error.writeAccessLost = You no longer have write access to the Zotero group '%S', and files you've added or edited cannot be synced to the server. From dcfdf27c0b8348fa6e29b7768d0a01339e0ad310 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Wed, 3 Oct 2012 14:53:51 -0400 Subject: [PATCH 13/14] Make item-specific fields override base fields when specified --- chrome/content/zotero/xpcom/translation/translate_item.js | 7 ++++++- chrome/content/zotero/xpcom/utilities.js | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/translation/translate_item.js b/chrome/content/zotero/xpcom/translation/translate_item.js index 2a3377d320..8cff062927 100644 --- a/chrome/content/zotero/xpcom/translation/translate_item.js +++ b/chrome/content/zotero/xpcom/translation/translate_item.js @@ -385,8 +385,13 @@ Zotero.Translate.ItemSaver.prototype = { // try to map from base field if(Zotero.ItemFields.isBaseField(fieldID)) { fieldID = Zotero.ItemFields.getFieldIDFromTypeAndBase(typeID, fieldID); + + // Skip mapping if item field already exists + var fieldName = Zotero.ItemFields.getName(fieldID); + if(item[fieldName]) continue; + if(fieldID) { - Zotero.debug("Translate: Mapping "+field+" to "+Zotero.ItemFields.getName(fieldID), 5); + Zotero.debug("Translate: Mapping "+field+" to "+fieldName, 5); } } diff --git a/chrome/content/zotero/xpcom/utilities.js b/chrome/content/zotero/xpcom/utilities.js index e64a8fcde2..ae17c35450 100644 --- a/chrome/content/zotero/xpcom/utilities.js +++ b/chrome/content/zotero/xpcom/utilities.js @@ -1262,7 +1262,9 @@ Zotero.Utilities = { // map from base field if possible if((itemFieldID = Zotero.ItemFields.getFieldIDFromTypeAndBase(typeID, fieldID))) { - newItem[Zotero.ItemFields.getName(itemFieldID)] = val; + var fieldName = Zotero.ItemFields.getName(itemFieldID); + // Only map if item field does not exist + if(!newItem[fieldName]) newItem[fieldName] = val; continue; // already know this is valid } From bdeff96162b273f8dd4870cee786a596bca2acd6 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Wed, 3 Oct 2012 17:54:21 -0400 Subject: [PATCH 14/14] Don't skip base fields that are mapped to a field with the same name --- chrome/content/zotero/xpcom/translation/translate_item.js | 2 +- chrome/content/zotero/xpcom/utilities.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/translation/translate_item.js b/chrome/content/zotero/xpcom/translation/translate_item.js index 8cff062927..fb4db78d41 100644 --- a/chrome/content/zotero/xpcom/translation/translate_item.js +++ b/chrome/content/zotero/xpcom/translation/translate_item.js @@ -388,7 +388,7 @@ Zotero.Translate.ItemSaver.prototype = { // Skip mapping if item field already exists var fieldName = Zotero.ItemFields.getName(fieldID); - if(item[fieldName]) continue; + if(fieldName !== field && item[fieldName]) continue; if(fieldID) { Zotero.debug("Translate: Mapping "+field+" to "+fieldName, 5); diff --git a/chrome/content/zotero/xpcom/utilities.js b/chrome/content/zotero/xpcom/utilities.js index ae17c35450..b7df62eb92 100644 --- a/chrome/content/zotero/xpcom/utilities.js +++ b/chrome/content/zotero/xpcom/utilities.js @@ -1264,7 +1264,7 @@ Zotero.Utilities = { if((itemFieldID = Zotero.ItemFields.getFieldIDFromTypeAndBase(typeID, fieldID))) { var fieldName = Zotero.ItemFields.getName(itemFieldID); // Only map if item field does not exist - if(!newItem[fieldName]) newItem[fieldName] = val; + if(fieldName !== field && !newItem[fieldName]) newItem[fieldName] = val; continue; // already know this is valid }