- fix export when dataMode is undefined (translate architecture should assume plain text)

- don't use "null" as a file extension
This commit is contained in:
Simon Kornblith 2011-01-17 07:42:22 +00:00
parent 0256f5b980
commit 259c286db7
2 changed files with 6 additions and 3 deletions

View File

@ -65,9 +65,9 @@ Zotero_File_Exporter.prototype.save = function() {
fp.appendFilters(Components.interfaces.nsIFilePicker.filterAll);
} else {
// if the result will be a file, append an extension and use filters
fp.defaultString = this.name+"."+io.selectedTranslator.target;
fp.defaultString = this.name+(io.selectedTranslator.target ? "."+io.selectedTranslator.target : "");
fp.defaultExtension = io.selectedTranslator.target;
fp.appendFilter(io.selectedTranslator.label, "*."+io.selectedTranslator.target);
fp.appendFilter(io.selectedTranslator.label, "*."+(io.selectedTranslator.target ? io.selectedTranslator.target : "*"));
}
var rv = fp.show();

View File

@ -84,6 +84,7 @@ Zotero.Translate.SandboxManager.prototype = {
return object[localKey].apply(object, args);
};
attachTo[localKey].name = localKey;
// attach members
if(!(object instanceof Components.interfaces.nsISupports)) {
@ -347,7 +348,7 @@ Zotero.Translate.IO.Write = function(file, mode, charset) {
.createInstance(Components.interfaces.nsIFileOutputStream);
this._rawStream.init(file, 0x02 | 0x08 | 0x20, 0664, 0); // write, create, truncate
this._writtenToStream = false;
if(mode) this.reset(mode, charset);
if(mode || charset) this.reset(mode, charset);
}
Zotero.Translate.IO.Write.prototype = {
@ -372,6 +373,8 @@ Zotero.Translate.IO.Write.prototype = {
},
"write":function(data) {
if(!this._charset) this.setCharacterSet("UTF-8");
if(!this._writtenToStream && this._charset.substr(this._charset.length-4) == "xBOM"
&& BOMs[this._charset.substr(0, this._charset.length-4).toUpperCase()]) {
// If stream has not yet been written to, and a UTF type has been selected, write BOM