Fix EPUB attachments with wrong MIME type on view

Fixes #3320
This commit is contained in:
Abe Jellinek 2023-08-15 17:53:05 -04:00
parent 7b26dab2f2
commit 17daf9fe8d

View file

@ -4708,11 +4708,13 @@ var ZoteroPane = new function()
if(typeof itemIDs != "object") itemIDs = [itemIDs];
var launchFile = async (path, contentType, itemID) => {
// Fix blank PDF attachment MIME type
if (!contentType) {
// Fix blank PDF MIME type and incorrect EPUB MIME type
if (!contentType || contentType === 'application/epub') {
let item = await Zotero.Items.getAsync(itemID);
let path = await item.getFilePathAsync();
let type = 'application/pdf';
let type = contentType === 'application/epub'
? 'application/epub+zip'
: 'application/pdf';
if (Zotero.MIME.sniffForMIMEType(await Zotero.File.getSample(path)) == type) {
contentType = type;
item.attachmentContentType = type;