From e27d90797339ab2368e285b5b888049b54a846dc Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Sun, 7 Jun 2015 16:05:53 -0400 Subject: [PATCH] Throw an error if HTTP request yields non-OK in importFromURL() --- chrome/content/zotero/xpcom/attachments.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/chrome/content/zotero/xpcom/attachments.js b/chrome/content/zotero/xpcom/attachments.js index 7582b70f18..4271728aca 100644 --- a/chrome/content/zotero/xpcom/attachments.js +++ b/chrome/content/zotero/xpcom/attachments.js @@ -258,6 +258,13 @@ Zotero.Attachments = new function(){ var browser = Zotero.HTTP.processDocuments( url, function() { + let channel = browser.docShell.currentDocumentChannel; + if (channel && (channel instanceof Components.interfaces.nsIHttpChannel)) { + if (channel.responseStatus < 200 || channel.responseStatus >= 400) { + deferred.reject(new Error("Invalid response "+channel.responseStatus+" "+channel.responseStatusText+" for '"+url+"'")); + return; + } + } return Zotero.Attachments.importFromDocument({ libraryID: libraryID, document: browser.contentDocument,