[gnome-documents] pdf-loader: quote the file path before passing it to unoconv



commit 11c4440470d0f0bf2fd427f23e23078c95653836
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Thu Sep 29 15:25:29 2011 -0400

    pdf-loader: quote the file path before passing it to unoconv
    
    This fixes unoconv crashing on files with spaces in their names.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=660382

 src/lib/gd-pdf-loader.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/src/lib/gd-pdf-loader.c b/src/lib/gd-pdf-loader.c
index 908cf7a..81ea72f 100644
--- a/src/lib/gd-pdf-loader.c
+++ b/src/lib/gd-pdf-loader.c
@@ -443,7 +443,7 @@ unoconv_child_watch_cb (GPid pid,
 static void
 pdf_load_job_openoffice_refresh_cache (PdfLoadJob *job)
 {
-  gchar *doc_path, *cmd;
+  gchar *doc_path, *cmd, *quoted_path;
   GFile *file;
   gint argc;
   GPid pid;
@@ -453,16 +453,19 @@ pdf_load_job_openoffice_refresh_cache (PdfLoadJob *job)
   /* build the temporary PDF file path */
   file = g_file_new_for_uri (job->uri);
   doc_path = g_file_get_path (file);
+  quoted_path = g_shell_quote (doc_path);
+
   g_object_unref (file);
+  g_free (doc_path);
 
   /* call into the unoconv executable to convert the OpenOffice document
    * to the temporary PDF.
    */
-  cmd = g_strdup_printf ("unoconv -f pdf -o %s %s", job->pdf_path, doc_path);
+  cmd = g_strdup_printf ("unoconv -f pdf -o %s %s", job->pdf_path, quoted_path);
   g_shell_parse_argv (cmd, &argc, &argv, &error);
 
   g_free (cmd);
-  g_free (doc_path);
+  g_free (quoted_path);
 
   if (error != NULL) {
     pdf_load_job_complete_error (job, error);



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