Don't assume "text/" MIME types can be opened internally
Previously, dragging a Python script ("text/x-python-script") would trigger an open/save dialog (at least on OS X), since Firefox was under the impression that it couldn't read the file.
This commit is contained in:
parent
7dbe6d728a
commit
77f422039f
|
@ -89,6 +89,7 @@ Zotero.Attachments = new function(){
|
|||
|
||||
var mimeType = Zotero.MIME.getMIMETypeFromFile(newFile);
|
||||
|
||||
|
||||
attachmentItem.attachmentMIMEType = mimeType;
|
||||
attachmentItem.attachmentPath = this.getPath(newFile, this.LINK_MODE_IMPORTED_FILE);
|
||||
attachmentItem.save();
|
||||
|
@ -1325,8 +1326,7 @@ Zotero.Attachments = new function(){
|
|||
}
|
||||
|
||||
var ext = Zotero.File.getExtension(file);
|
||||
if (mimeType.substr(0, 5)!='text/' ||
|
||||
!Zotero.MIME.hasInternalHandler(mimeType, ext)){
|
||||
if (!Zotero.MIME.hasInternalHandler(mimeType, ext)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
Zotero.MIME = new function(){
|
||||
this.isTextType = isTextType;
|
||||
this.isExternalTextExtension = isExternalTextExtension;
|
||||
this.getPrimaryExtension = getPrimaryExtension;
|
||||
this.sniffForMIMEType = sniffForMIMEType;
|
||||
this.sniffForBinary = sniffForBinary;
|
||||
|
@ -92,14 +91,6 @@ Zotero.MIME = new function(){
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* Check if file extension should be forced to open externally
|
||||
*/
|
||||
function isExternalTextExtension(ext){
|
||||
return typeof _externalTextExtensions[ext] != 'undefined';
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Our own wrapper around the MIME service's getPrimaryExtension() that
|
||||
* works a little better
|
||||
|
@ -326,20 +317,11 @@ Zotero.MIME = new function(){
|
|||
* do what we need
|
||||
*/
|
||||
function hasNativeHandler(mimeType, ext) {
|
||||
if (mimeType.match(/^text\//)) {
|
||||
if (isExternalTextExtension(ext)){
|
||||
Zotero.debug(mimeType + " file has extension '" + ext + "' that should be handled externally");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_nativeMIMETypes[mimeType]){
|
||||
Zotero.debug('MIME type ' + mimeType + ' can be handled natively');
|
||||
return true;
|
||||
}
|
||||
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -350,9 +332,8 @@ Zotero.MIME = new function(){
|
|||
* Similar to hasNativeHandler() but also includes plugins
|
||||
*/
|
||||
function hasInternalHandler(mimeType, ext) {
|
||||
var isNative = hasNativeHandler(mimeType, ext);
|
||||
if (isNative !== null) {
|
||||
return isNative;
|
||||
if (hasNativeHandler(mimeType, ext)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(mimeType === "application/pdf"
|
||||
|
|
Loading…
Reference in New Issue
Block a user