Allow the user to dump databases qith quotes or backslashes in the name.
authordpage <dpage@a7884b65-44f6-0310-8a51-81a127f17b15>
Mon, 17 Mar 2008 16:27:05 +0000 (16:27 +0000)
committerdpage <dpage@a7884b65-44f6-0310-8a51-81a127f17b15>
Mon, 17 Mar 2008 16:27:05 +0000 (16:27 +0000)
git-svn-id: svn://svn.pgadmin.org/trunk/pgadmin3@7169 a7884b65-44f6-0310-8a51-81a127f17b15

pgadmin/frm/frmBackup.cpp
pgadmin/frm/frmRestore.cpp
pgadmin/include/utils/misc.h
pgadmin/utils/misc.cpp

index 068f4c44691b03273c3e91e89683e6533aae72f8..5055ae9c43a2f36a3495fafba743c30bc614b20e 100644 (file)
@@ -294,7 +294,7 @@ wxString frmBackup::getCmdPart2()
                }
     }
 
-    cmd.Append(wxT(" ") + object->GetDatabase()->GetQuotedIdentifier());
+    cmd.Append(wxT(" ") + commandLineCleanOption(object->GetDatabase()->GetQuotedIdentifier()));
 
     return cmd;
 }
index d7dd5c2f923ffcfa6880a4d79287a4cbe76c66fe..aa57b7a8de46d245aa12ce0757e498a891f0e2b5 100644 (file)
@@ -279,7 +279,7 @@ wxString frmRestore::getCmdPart1()
     cmd += wxT(" -h ") + server->GetName()
          + wxT(" -p ") + NumToStr((long)server->GetPort())
          + wxT(" -U ") + qtIdent(server->GetUsername())
-         + wxT(" -d ") + qtIdent(object->GetDatabase()->GetName());
+         + wxT(" -d ") + commandLineCleanOption(object->GetDatabase()->GetQuotedIdentifier());
     return cmd;
 }
 
index 2e02eed4842d3ccb6c5b2f7ad56e32d46f56bbb6..f0bc1cbf536d7d4ac2e27999b1854ce7c27d6440 100644 (file)
@@ -230,3 +230,4 @@ enum        // depends on pgaFactory::addImage order!
 
 // File/directory name cleanup
 wxString sanitizePath(const wxString &path);
+wxString commandLineCleanOption(const wxString &option);
index 53f3e04a20287677a98eb5de0cf10aab5c165628..9420e3c09c3bd551e91f1b3ad974e6d27937d891 100644 (file)
@@ -1171,4 +1171,38 @@ wxString sanitizePath(const wxString &path)
     }
 
        return wxEmptyString;
-}
\ No newline at end of file
+}
+
+// Fixup a (quoted) string for use on the command line
+wxString commandLineCleanOption(const wxString &option)
+{
+    wxString tmp;
+    bool wasQuoted = false;
+
+    if (option.StartsWith(wxT("\"")) && option.EndsWith(wxT("\"")))
+    {
+        tmp = option.AfterFirst((wxChar)'"').BeforeLast((wxChar)'"');
+        wasQuoted = true;
+    }
+    else
+        tmp = option;
+
+#ifdef __WXMSW__
+    if (wasQuoted)
+        tmp.Replace(wxT("\"\""), wxT("\"\"\""));
+    else
+    {
+        tmp.Replace(wxT("\""), wxT("\"\""));
+        tmp.Replace(wxT("\\"), wxT("\\\\"));
+    }
+#else
+    tmp.Replace(wxT("\\"), wxT("\\\\"));
+    tmp.Replace(wxT("\"\""), wxT("\\\""));
+#endif
+
+    if (wasQuoted)
+        tmp = wxT("\"") + tmp + wxT("\"");
+
+    return tmp;
+}
+