From f28cb224802f72ede5fc2afe24e062fc53827eaa Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sun, 20 Dec 2009 09:30:26 +0000 Subject: [PATCH] Fixes #607, Don't show annotations toolbar on MIME types it doesn't support --- chrome/content/zotero/xpcom/annotate.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/annotate.js b/chrome/content/zotero/xpcom/annotate.js index 5db2bc9816..90a8be6251 100644 --- a/chrome/content/zotero/xpcom/annotate.js +++ b/chrome/content/zotero/xpcom/annotate.js @@ -58,7 +58,18 @@ Zotero.Annotate = new function() { this.getAnnotationIDFromURL = function(url) { const attachmentRe = /^zotero:\/\/attachment\/([0-9]+)\/$/; var m = attachmentRe.exec(url); - return m ? m[1] : false; + if (m) { + var id = m[1]; + var item = Zotero.Items.get(id); + var mimeType = item.attachmentMIMEType; + var file = item.getFile(); + var ext = Zotero.File.getExtension(file); + if (mimeType == 'text/plain' || !Zotero.MIME.hasNativeHandler(mimeType, ext)) { + return false; + } + return id; + } + return false; } /**