fix #1578 enable export with filename composed of non-alphanumerical characters

This commit is contained in:
Vern1erCa11per 2018-04-20 17:32:57 +09:00
parent 3c4002ee2c
commit 38877f1449

View File

@ -30,7 +30,6 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
function ExporterManager(button) { function ExporterManager(button) {
this._button = button; this._button = button;
this._initializeUI(); this._initializeUI();
@ -117,6 +116,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) { ExporterManager.handlers.exportTripleloader = function(format) {
if (!theProject.overlayModels.freebaseProtograph) { if (!theProject.overlayModels.freebaseProtograph) {
alert($.i18n._('triple-loader')["warning-align"]); alert($.i18n._('triple-loader')["warning-align"]);
@ -141,7 +145,7 @@ ExporterManager.handlers.exportRows = function(format, ext) {
}; };
ExporterManager.prepareExportRowsForm = function(format, includeEngine, ext) { ExporterManager.prepareExportRowsForm = function(format, includeEngine, ext) {
var name = $.trim(theProject.metadata.name.replace(/\W/g, ' ')).replace(/\s+/g, '-'); var name = ExporterManager.stripNonFileChars(theProject.metadata.name);
var form = document.createElement("form"); var form = document.createElement("form");
$(form) $(form)
.css("display", "none") .css("display", "none")
@ -168,7 +172,7 @@ ExporterManager.prepareExportRowsForm = function(format, includeEngine, ext) {
}; };
ExporterManager.handlers.exportProject = function() { ExporterManager.handlers.exportProject = function() {
var name = $.trim(theProject.metadata.name.replace(/\W/g, ' ')).replace(/\s+/g, '-'); var name = ExporterManager.stripNonFileChars(theProject.metadata.name);
// dialog // dialog
var dialog = $(DOM.loadHTML("core", "scripts/dialogs/export-project-dialog.html")); var dialog = $(DOM.loadHTML("core", "scripts/dialogs/export-project-dialog.html"));
var _elmts = DOM.bind(dialog); var _elmts = DOM.bind(dialog);
@ -252,7 +256,7 @@ ExporterManager.handlers.exportProject = function() {
ExporterManager.handlers.projectDataPackage = function() { ExporterManager.handlers.projectDataPackage = function() {
function save(jsonMetadata) { 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"); var form = document.createElement("form");
$(form) $(form)
.css("display", "none") .css("display", "none")