[glom/glom-1-12] Allow new files to have quotes in their titles.



commit d37d3ba141f26715ff1961d493010fcba44f8d1d
Author: Murray Cumming <murrayc murrayc com>
Date:   Mon Jan 25 11:09:06 2010 +0100

    Allow new files to have quotes in their titles.
    
    * glom/frame_glom.cc:
    connection_request_password_and_choose_new_database_name():
    Remove quotes (and other unusual characters) from the generated
    database name, to avoid errors from the database backend.
    Bug #607957 (Michael Hasselmann)

 ChangeLog          |   10 ++++++++++
 glom/frame_glom.cc |   12 ++++++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 337df9b..eb74d89 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2010-01-25 Murray Cumming <murrayc murrayc com>
+
+	Allow new files to have quotes in their titles.
+
+	* glom/frame_glom.cc:
+	connection_request_password_and_choose_new_database_name():
+	Remove quotes (and other unusual characters) from the generated
+	database name, to avoid errors from the database backend.
+	Bug #607957 (Michael Hasselmann)
+
 1.12.5 (stable):
 
 2010-01-20  Murray Cumming  <murrayc murrayc com>
diff --git a/glom/frame_glom.cc b/glom/frame_glom.cc
index 3f05e20..5b86d92 100644
--- a/glom/frame_glom.cc
+++ b/glom/frame_glom.cc
@@ -2319,7 +2319,15 @@ bool Frame_Glom::connection_request_password_and_choose_new_database_name()
   {
     Glib::ustring database_name_possible;
     if(extra_num == 0)
-      database_name_possible = database_name; //Try the original name first.
+    {
+      //Try the original name first,
+      //removing any characters that are likely to cause problems when used in a SQL identifier name:
+      database_name_possible = Utils::trim_whitespace(database_name);
+      database_name_possible = Utils::string_replace(database_name_possible, "\"", "");
+      database_name_possible = Utils::string_replace(database_name_possible, "'", "");
+      database_name_possible = Utils::string_replace(database_name_possible, "\t", "");
+      database_name_possible = Utils::string_replace(database_name_possible, "\n", "");
+    }
     else
     {
       //Create a new database name by appending a number to the original name:
@@ -2363,7 +2371,7 @@ bool Frame_Glom::connection_request_password_and_choose_new_database_name()
         //The connection to the server is OK, but the specified database does not exist.
         //That's good - we were looking for an unused database name.
 
-        std::cout << "debug: unused database name found: " << database_name_possible << std::endl;
+        //std::cout << "debug: unused database name found: " << database_name_possible << std::endl;
         document->set_connection_database(database_name_possible);
 
         // Remember host and port if the document is not self hosted



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]