commit 3b9f23baf3bfbe42d299d9ed2d38b3d1ee281a01
parent 31943dfba7eff72578a7fa8c3dda8067bfe67de6
Author: Dan Stillman <dstillman@zotero.org>
Date: Wed, 25 Nov 2009 01:31:31 +0000
Fix open/save window importing BibTeX files without UTF-8 BOM in auto mode -- just default to UTF-8
Diffstat:
3 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/chrome/content/zotero/xpcom/file.js b/chrome/content/zotero/xpcom/file.js
@@ -245,12 +245,14 @@ Zotero.File = new function(){
*/
function getCharsetFromFile(file, mimeType, callback, args){
if (!file || !file.exists()){
- return false;
+ callback(false, args);
+ return;
}
- if (mimeType.substr(0, 5)!='text/' ||
- !Zotero.MIME.hasInternalHandler(mimeType, this.getExtension(file))){
- return false;
+ if (mimeType.substr(0, 5) != 'text/' ||
+ !Zotero.MIME.hasInternalHandler(mimeType, this.getExtension(file))) {
+ callback(false, args);
+ return;
}
var browser = Zotero.Browser.createHiddenBrowser();
diff --git a/chrome/content/zotero/xpcom/mime.js b/chrome/content/zotero/xpcom/mime.js
@@ -79,7 +79,8 @@ Zotero.MIME = new function(){
var _externalTextExtensions = {
graffle: true,
mm: true,
- opml: true
+ opml: true,
+ bib: true
};
@@ -324,7 +325,7 @@ Zotero.MIME = new function(){
function hasNativeHandler(mimeType, ext) {
if (mimeType.match(/^text\//)) {
if (isExternalTextExtension(ext)){
- Zotero.debug('text file has extension that should be handled externally');
+ Zotero.debug(mimeType + " file has extension '" + ext + "' that should be handled externally");
return false;
}
return true;
diff --git a/chrome/content/zotero/xpcom/translate.js b/chrome/content/zotero/xpcom/translate.js
@@ -1799,7 +1799,8 @@ Zotero.Translate.prototype._importSniffCharacterSet = function(callback) {
var me = this;
Zotero.File.getCharsetFromFile(this.location, "text/plain",
function(charset) {
- me._charset = charset;
+ // Default to UTF-8 if no charset available
+ me._charset = charset ? charset : "UTF-8";
me._importDoneSniffing(charset);
});
} else {