[glom] Use Glib::shell_quote() when spawning tar.



commit 973e05f0e81611857ecb24d85c41d7c48919879b
Author: Murray Cumming <murrayc murrayc com>
Date:   Wed Nov 9 22:08:25 2011 +0100

    Use Glib::shell_quote() when spawning tar.
    
    * glom/libglom/document/document.cc: Use Glib::shell_quote()
    when spawning tar, instead of manually adding quotes.

 ChangeLog                         |    7 +++++++
 glom/libglom/document/document.cc |   15 ++++++++-------
 2 files changed, 15 insertions(+), 7 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 64afb75..e9fddc3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2011-11-09  Murray Cumming  <murrayc murrayc com>
 
+	Use Glib::shell_quote() when spawning tar.
+
+	* glom/libglom/document/document.cc: Use Glib::shell_quote()
+	when spawning tar, instead of manually adding quotes.
+
+2011-11-09  Murray Cumming  <murrayc murrayc com>
+
 	PostgreSQL backend: Use g_shell_quote().
 
 	* glom/libglom/connectionpool_backends/postgres.[h|cc]:
diff --git a/glom/libglom/document/document.cc b/glom/libglom/document/document.cc
index 00d71b3..1ac9dc6 100644
--- a/glom/libglom/document/document.cc
+++ b/glom/libglom/document/document.cc
@@ -36,6 +36,7 @@
 #include <giomm/file.h>
 #include <glibmm/miscutils.h>
 #include <glibmm/convert.h>
+#include <glibmm/shell.h>
 //#include <libglom/busy_cursor.h>
 
 #include <libglom/connectionpool.h>
@@ -4609,13 +4610,13 @@ Glib::ustring Document::save_backup_file(const Glib::ustring& uri, const SlotPro
       const std::string tarball_path = path_dir + ".tar.gz";
       //TODO: Find some way to do this without using the command-line,
       //which feels fragile:
-      const std::string command_tar = "\"" + path_tar + "\"" +
+      const std::string command_tar = Glib::shell_quote(path_tar) +
         " --force-local --no-wildcards" + //Avoid side-effects of special characters.
         " --remove-files" +
         " -czf"
-        " \"" + tarball_path + "\"" +
-        " --directory \"" + parent_dir + "\"" + //This must be right before the mention of the file name:
-        " \"" + basename + "\"";
+        " " + Glib::shell_quote(tarball_path) +
+        " --directory " + Glib::shell_quote(parent_dir) + //This must be right before the mention of the file name:
+        " " + Glib::shell_quote(basename);
 
       //std::cout << "DEBUG: command_tar=" << command_tar << std::endl;
 
@@ -4652,11 +4653,11 @@ Glib::ustring Document::restore_backup_file(const Glib::ustring& backup_uri, con
   //Untar into the tmp directory:
   //TODO: Find some way to do this without using the command-line,
   //which feels fragile:
-  const std::string command_tar = "\"" + path_tar + "\"" +
+  const std::string command_tar = Glib::shell_quote(path_tar) +
     " --force-local --no-wildcards" + //Avoid side-effects of special characters.
     " -xzf"
-    " \"" + filename_tarball + "\"" +
-    " --directory \"" + path_tmp + "\"";
+    " " + Glib::shell_quote(filename_tarball) +
+    " --directory " + Glib::shell_quote(path_tmp);
 
   //std::cout << "DEBUG: command_tar=" << command_tar << std::endl;
 



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