diff --git a/extensions/wikidata/module/scripts/dialogs/schema-alignment-dialog.js b/extensions/wikidata/module/scripts/dialogs/schema-alignment-dialog.js index f674e7a8c..cbafa13ac 100644 --- a/extensions/wikidata/module/scripts/dialogs/schema-alignment-dialog.js +++ b/extensions/wikidata/module/scripts/dialogs/schema-alignment-dialog.js @@ -32,11 +32,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ var SchemaAlignment = {}; - -SchemaAlignment._cleanName = function(s) { - return s.replace(/\W/g, " ").replace(/\s+/g, " ").toLowerCase(); -}; - var SchemaAlignmentDialog = {}; /** diff --git a/main/webapp/modules/core/scripts/dialogs/sql-exporter-dialog.js b/main/webapp/modules/core/scripts/dialogs/sql-exporter-dialog.js index 416e3d874..db30cf18e 100755 --- a/main/webapp/modules/core/scripts/dialogs/sql-exporter-dialog.js +++ b/main/webapp/modules/core/scripts/dialogs/sql-exporter-dialog.js @@ -295,7 +295,7 @@ function SqlExporterDialog(options) { SqlExporterDialog.prototype._configureUIFromOptionCode = function(options) { - this._elmts.tableNameTextBox.val(theProject.metadata.name); + this._elmts.tableNameTextBox.val(theProject.metadata.name.replace(/\W/g, ' ').replace(/\s+/g, '_')); this._elmts.sqlExportOutputEmptyRowsCheckbox.attr('checked', 'checked'); this._elmts.sqlExportTrimAllColumnsCheckbox.attr('checked', 'checked'); this._elmts.nullCellValueToEmptyStringLabel.attr('checked', 'checked'); @@ -334,8 +334,8 @@ function SqlExporterDialog(options) { return false; } - var name = $.trim(theProject.metadata.name.replace(/\W/g, ' ')).replace(/\s+/g, '-'); - + var name = ExporterManager.stripNonFileChars(theProject.metadata.name); + var format = options.format; var encoding = options.encoding; @@ -373,7 +373,7 @@ function SqlExporterDialog(options) { }; SqlExporterDialog.prototype._prepareSqlExportRowsForm = 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"); $(form) .css("display", "none") @@ -453,6 +453,7 @@ function SqlExporterDialog(options) { var self = this; this._elmts.columnListTable.find('.sql-exporter-dialog-row').each(function() { if ($(this).find('input[type="checkbox"]')[0].checked) { + // TODO: Ideally we'd like to let the user preview the names in their cleaned SQL-legal form var name = this.getAttribute('column'); var rowIndex = this.getAttribute('rowIndex'); diff --git a/main/webapp/modules/core/scripts/dialogs/templating-exporter-dialog.js b/main/webapp/modules/core/scripts/dialogs/templating-exporter-dialog.js index 88dbd5d44..330214e86 100644 --- a/main/webapp/modules/core/scripts/dialogs/templating-exporter-dialog.js +++ b/main/webapp/modules/core/scripts/dialogs/templating-exporter-dialog.js @@ -143,7 +143,7 @@ TemplatingExporterDialog.prototype._updatePreview = function() { }; TemplatingExporterDialog.prototype._export = function() { - 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") @@ -173,4 +173,4 @@ TemplatingExporterDialog.prototype._export = function() { form.submit(); document.body.removeChild(form); -}; \ No newline at end of file +}; diff --git a/main/webapp/modules/core/scripts/index/default-importing-controller/parsing-panel.js b/main/webapp/modules/core/scripts/index/default-importing-controller/parsing-panel.js index 2e2202ee6..a874915cd 100644 --- a/main/webapp/modules/core/scripts/index/default-importing-controller/parsing-panel.js +++ b/main/webapp/modules/core/scripts/index/default-importing-controller/parsing-panel.js @@ -60,7 +60,7 @@ Refine.DefaultImportingController.prototype._showParsingPanel = function(hasFile if (!(this._projectName) && this._job.config.fileSelection.length > 0) { var index = this._job.config.fileSelection[0]; var record = this._job.config.retrievalRecord.files[index]; - this._projectName = $.trim(record.fileName.replace(/\W/g, ' ').replace(/\s+/g, ' ')); + this._projectName = $.trim(record.fileName.replace(/[\._-]/g, ' ').replace(/\s+/g, ' ')); } if (this._projectName) { this._parsingPanelElmts.projectNameInput[0].value = this._projectName; diff --git a/main/webapp/modules/core/scripts/project/exporters.js b/main/webapp/modules/core/scripts/project/exporters.js index a56014b1f..559302914 100644 --- a/main/webapp/modules/core/scripts/project/exporters.js +++ b/main/webapp/modules/core/scripts/project/exporters.js @@ -105,8 +105,9 @@ 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, '-'); + // prohibited characters in file name of linux (/) and windows (\/:*?"<>|) + // and MacOS https://stackoverflow.com/a/47455094/167425 + return $.trim(name.replace(/[\\*\/:;,?"<>|#]/g, ' ')).replace(/\s+/g, '-'); }; ExporterManager.handlers.exportRows = function(format, ext) { @@ -121,7 +122,7 @@ ExporterManager.handlers.exportRows = function(format, ext) { }; ExporterManager.prepareExportRowsForm = function(format, includeEngine, ext) { - var name = $.trim(theProject.metadata.name.replace(/\W/g, ' ')).replace(/\s+/g, '-'); + var name = encodeURI(ExporterManager.stripNonFileChars(theProject.metadata.name)); var form = document.createElement("form"); $(form) .css("display", "none") @@ -151,7 +152,7 @@ ExporterManager.prepareExportRowsForm = function(format, includeEngine, ext) { }; ExporterManager.handlers.exportProjectToLocal = function() { - var name = ExporterManager.stripNonFileChars(theProject.metadata.name); + var name = encodeURI(ExporterManager.stripNonFileChars(theProject.metadata.name)); var form = document.createElement("form"); $(form) .css("display", "none")