[glom] Allow new files to have quotes in their titles.



commit 814eeec8dc7a736d237bab1f2cae5e64a45327c4
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 b2ace2a..3857a97 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) 
+
 2010-01-24  Murray Cumming  <murrayc murrayc com>
 
 	* ldtp/central-info.xml.example: Added an example central-info.xml, as 
diff --git a/glom/frame_glom.cc b/glom/frame_glom.cc
index 6d42620..b7fca96 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]