From b383fb6aa7caba5cc2c9ad2b357a9211d737e103 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 7 Dec 2006 14:12:00 +0000 Subject: [PATCH] More snapshot-related tweaks: - Only use saveDocument() for text/html snapshots - Add 'application/xhtml+xml' and 'application/xml' as native MIME types - When loading attachment, check recorded MIME type first before detecting --- chrome/content/zotero/overlay.js | 8 +++++++- chrome/content/zotero/xpcom/attachments.js | 2 +- chrome/content/zotero/xpcom/mime.js | 16 ++-------------- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js index f6d7d678bb..7736b0494e 100644 --- a/chrome/content/zotero/overlay.js +++ b/chrome/content/zotero/overlay.js @@ -1069,7 +1069,13 @@ var ZoteroPane = new function() { var file = attachment.getFile(); if (file){ - if (Zotero.MIME.fileHasInternalHandler(file)) + var mimeType = attachment.getAttachmentMimeType(); + if (mimeType) { + var ext = Zotero.File.getExtension(file); + var internal = Zotero.MIME.hasInternalHandler(mimeType, ext); + } + + if (internal || Zotero.MIME.fileHasInternalHandler(file)) { window.loadURI(attachment.getLocalFileURL()); } diff --git a/chrome/content/zotero/xpcom/attachments.js b/chrome/content/zotero/xpcom/attachments.js index e49b343234..3f46ff3f8f 100644 --- a/chrome/content/zotero/xpcom/attachments.js +++ b/chrome/content/zotero/xpcom/attachments.js @@ -442,7 +442,7 @@ Zotero.Attachments = new function(){ // leaving the transaction open if the callback never triggers Zotero.DB.commitTransaction(); - if (Zotero.MIME.isDocumentType(mimeType)) { + if (mimeType == 'text/html') { Zotero.debug('Saving with saveDocument()'); wbp.saveDocument(document, file, destDir, mimeType, encodingFlags, false); } diff --git a/chrome/content/zotero/xpcom/mime.js b/chrome/content/zotero/xpcom/mime.js index a36c6b6344..d98bb5a59d 100644 --- a/chrome/content/zotero/xpcom/mime.js +++ b/chrome/content/zotero/xpcom/mime.js @@ -26,7 +26,6 @@ Zotero.MIME = new function(){ this.sniffForBinary = sniffForBinary; this.getMIMETypeFromData = getMIMETypeFromData; this.getMIMETypeFromFile = getMIMETypeFromFile; - this.isDocumentType = isDocumentType; this.hasNativeHandler = hasNativeHandler; this.hasInternalHandler = hasInternalHandler; this.fileHasInternalHandler = fileHasInternalHandler; @@ -42,14 +41,6 @@ Zotero.MIME = new function(){ ["