Merge pull request #1579 from Vern1erCa11per/fix/allow/nonnumerical/exportname

fix #1578 enable export with filename composed of non-alphanumerical …
This commit is contained in:
Jacky 2018-07-11 18:49:38 -04:00 committed by GitHub
commit 05abcd2d75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,4 @@
/*
Copyright 2010, Google Inc.
All rights reserved.
@ -30,7 +29,6 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
function ExporterManager(button) {
this._button = button;
this._initializeUI();
@ -111,6 +109,11 @@ ExporterManager.prototype._initializeUI = function() {
});
};
ExporterManager.stripNonFileChars = function(name) {
//prohibited characters in file name of linux (/) and windows (\/:*?"<>|)
return $.trim(name.replace(/[\\*\/:?"<>|]/g, ' ')).replace(/\s+/g, '-');
};
ExporterManager.handlers.exportTripleloader = function(format) {
if (!theProject.overlayModels.freebaseProtograph) {
alert($.i18n._('triple-loader')["warning-align"]);
@ -136,7 +139,6 @@ ExporterManager.handlers.exportRows = function(format, ext) {
ExporterManager.prepareExportRowsForm = function(format, includeEngine, ext) {
var name = $.trim(theProject.metadata.name.replace(/\W/g, ' ')).replace(/\s+/g, '-');
//alert("name:" + name);
var form = document.createElement("form");
$(form)
.css("display", "none")
@ -163,7 +165,7 @@ ExporterManager.prepareExportRowsForm = function(format, includeEngine, ext) {
};
ExporterManager.handlers.exportProject = function() {
var name = $.trim(theProject.metadata.name.replace(/\W/g, ' ')).replace(/\s+/g, '-');
var name = ExporterManager.stripNonFileChars(theProject.metadata.name);
// dialog
var dialog = $(DOM.loadHTML("core", "scripts/dialogs/export-project-dialog.html"));
var _elmts = DOM.bind(dialog);
@ -247,7 +249,7 @@ ExporterManager.handlers.exportProject = function() {
ExporterManager.handlers.projectDataPackage = function() {
function save(jsonMetadata) {
var name = $.trim(theProject.metadata.name.replace(/\W/g, ' ')).replace(/\s+/g, '-');
var name = ExporterManager.stripNonFileChars(theProject.metadata.name);
var form = document.createElement("form");
$(form)
.css("display", "none")