From 0ae6f1895ea94f7031156073629231c55a442512 Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Thu, 16 Jan 2014 19:56:58 +0100 Subject: [PATCH] Allow space characters in table and index names, disallow ` chars Spaces in table, index and field names are actually allowed by SQLite, so no need to check for them. However, "`" characters cause problems when appearing in SQL statements so disallow them instead. --- src/CreateIndexDialog.cpp | 4 +--- src/EditTableDialog.cpp | 3 +-- src/ImportCsvDialog.cpp | 5 ++--- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/CreateIndexDialog.cpp b/src/CreateIndexDialog.cpp index c02e47e2..68b4aaa9 100644 --- a/src/CreateIndexDialog.cpp +++ b/src/CreateIndexDialog.cpp @@ -52,10 +52,8 @@ void CreateIndexDialog::tableChanged(const QString& new_table) void CreateIndexDialog::checkInput() { - ui->editIndexName->setText(ui->editIndexName->text().trimmed()); - bool valid = true; - if(ui->editIndexName->text().isEmpty() || ui->editIndexName->text().contains(" ")) + if(ui->editIndexName->text().isEmpty() || ui->editIndexName->text().contains("`")) valid = false; int num_columns = 0; diff --git a/src/EditTableDialog.cpp b/src/EditTableDialog.cpp index 5c4d3c89..27bd16c4 100644 --- a/src/EditTableDialog.cpp +++ b/src/EditTableDialog.cpp @@ -149,9 +149,8 @@ void EditTableDialog::updateSqlText() void EditTableDialog::checkInput() { QString normTableName = ui->editTableName->text().trimmed(); - ui->editTableName->setText(normTableName); bool valid = true; - if(normTableName.isEmpty() || normTableName.contains(" ")) + if(normTableName.isEmpty() || normTableName.contains("`")) valid = false; if(ui->treeWidget->topLevelItemCount() == 0) valid = false; diff --git a/src/ImportCsvDialog.cpp b/src/ImportCsvDialog.cpp index 5b87acb4..9d239516 100644 --- a/src/ImportCsvDialog.cpp +++ b/src/ImportCsvDialog.cpp @@ -57,6 +57,7 @@ void ImportCsvDialog::accept() { // Remove invalid characters QString thisfield = curList.front(); + thisfield.replace("`", ""); thisfield.replace(" ", ""); thisfield.replace('"', ""); thisfield.replace("'",""); @@ -196,10 +197,8 @@ void ImportCsvDialog::updatePreview() void ImportCsvDialog::checkInput() { - ui->editName->setText(ui->editName->text().trimmed()); - bool valid = true; - if(ui->editName->text().isEmpty() || ui->editName->text().contains(" ")) + if(ui->editName->text().isEmpty() || ui->editName->text().contains("`")) valid = false; ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(valid);