From 430e43a6b6aa26d1ba1c30b07d2bad45466d1537 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Sun, 22 Jul 2012 01:48:18 -0400 Subject: [PATCH] Fix handling of MIME type mismatches --- .../zotero/xpcom/connector/translate_item.js | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/chrome/content/zotero/xpcom/connector/translate_item.js b/chrome/content/zotero/xpcom/connector/translate_item.js index 9b9fb6ebd..c5917e987 100644 --- a/chrome/content/zotero/xpcom/connector/translate_item.js +++ b/chrome/content/zotero/xpcom/connector/translate_item.js @@ -282,7 +282,7 @@ Zotero.Translate.ItemSaver.prototype = { } } - if(err) throw err; + if(err) Zotero.logError(err); }); }; @@ -360,21 +360,23 @@ Zotero.Translate.ItemSaver.prototype = { } } - attachment.mimeType = contentType; - attachment.linkMode = "imported_url"; - switch(contentType.toLowerCase()) { - case "application/pdf": - attachment.filename = baseName+".pdf"; - break; - case "text/html": - case "application/xhtml+xml": - attachment.filename = baseName+".html"; - break; - default: - attachment.filename = baseName; + if(!err) { + attachment.mimeType = contentType; + attachment.linkMode = "imported_url"; + switch(contentType.toLowerCase()) { + case "application/pdf": + attachment.filename = baseName+".pdf"; + break; + case "text/html": + case "application/xhtml+xml": + attachment.filename = baseName+".html"; + break; + default: + attachment.filename = baseName; + } + if(charset) attachment.charset = charset; + headersValidated = true; } - if(charset) attachment.charset = charset; - headersValidated = true; } // If we didn't validate the headers, cancel the request @@ -392,7 +394,7 @@ Zotero.Translate.ItemSaver.prototype = { // If there was an error, throw it now if(err) { attachmentCallback(attachment, false, err); - throw err; + Zotero.logError(err); } };