commit 77f422039f74deb73ab6775c21327be5730b5867
parent 7dbe6d728a3e282b9f6366acfb84a8940c566d05
Author: Dan Stillman <dstillman@zotero.org>
Date: Thu, 2 Aug 2012 09:08:49 -0400
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.
Diffstat:
2 files changed, 5 insertions(+), 24 deletions(-)
diff --git a/chrome/content/zotero/xpcom/attachments.js b/chrome/content/zotero/xpcom/attachments.js
@@ -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;
}
diff --git a/chrome/content/zotero/xpcom/mime.js b/chrome/content/zotero/xpcom/mime.js
@@ -25,7 +25,6 @@
Zotero.MIME = new function(){
this.isTextType = isTextType;
- this.isExternalTextExtension = isExternalTextExtension;
this.getPrimaryExtension = getPrimaryExtension;
this.sniffForMIMEType = sniffForMIMEType;
this.sniffForBinary = sniffForBinary;
@@ -93,14 +92,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"