From ae1e82494d900c0adaa0cecdc6b5edf8045286d8 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Wed, 16 Mar 2011 23:19:29 +0000 Subject: [PATCH] Fail to import files with bad URIs --- .../zotero/xpcom/translation/item_local.js | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/chrome/content/zotero/xpcom/translation/item_local.js b/chrome/content/zotero/xpcom/translation/item_local.js index 16a3fe539..fa01d6ecb 100644 --- a/chrome/content/zotero/xpcom/translation/item_local.js +++ b/chrome/content/zotero/xpcom/translation/item_local.js @@ -229,29 +229,30 @@ Zotero.Translate.ItemSaver.prototype = { var msg = "Error parsing attachment path: " + attachment.path; Zotero.logError(msg); Zotero.debug("Translate: " + msg, 2); + return; } - if (uri) { - try { - var file = uri.QueryInterface(Components.interfaces.nsIFileURL).file; - if (file.path == '/') { - var msg = "Error parsing attachment path: " + attachment.path; - Zotero.logError(msg); - Zotero.debug("Translate: " + msg, 2); - } - } - catch (e) { - var msg = "Error getting file from attachment path: " + attachment.path; + try { + var file = uri.QueryInterface(Components.interfaces.nsIFileURL).file; + if (file.path == '/') { + var msg = "Error parsing attachment path: " + attachment.path; Zotero.logError(msg); Zotero.debug("Translate: " + msg, 2); + return; } } + catch (e) { + var msg = "Error getting file from attachment path: " + attachment.path; + Zotero.logError(msg); + Zotero.debug("Translate: " + msg, 2); + return; + } - if (!file || !file.exists()) { + if (!file.exists()) { // use attachment title if possible, or else file leaf name var title = attachment.title; if(!title) { - title = file ? file.leafName : ''; + title = file.leafName; } var myID = Zotero.Attachments.createMissingAttachment(