[gvfs] gvfs-open: Do not alter uris before use



commit dd650d4a82ee369df960bc8e40024e75cad0ba88
Author: Ondrej Holy <oholy redhat com>
Date:   Tue May 19 12:36:28 2015 +0200

    gvfs-open: Do not alter uris before use
    
    Uri is altered before g_app_info_launch_default_for_uri, because of
    the following code (from the commit 95aac17):
    
    file = g_file_new_for_commandline_arg (location[i])
    uri = g_file_get_uri (file);
    
    Examples of uri changes:
    
    mailto:email -> mailto:///email
    ssh://user host -> sftp://user host/
    
    This patch cause that uri isn't preprocessed for locations with scheme
    (however absolute and relative paths are still preprocessed).
    
    https://bugzilla.gnome.org/show_bug.cgi?id=738690

 programs/gvfs-open.c |   26 +++++++++++++++++++-------
 1 files changed, 19 insertions(+), 7 deletions(-)
---
diff --git a/programs/gvfs-open.c b/programs/gvfs-open.c
index 81d7e2c..20e5c87 100644
--- a/programs/gvfs-open.c
+++ b/programs/gvfs-open.c
@@ -103,13 +103,25 @@ main (int argc, char *argv[])
 
   do
     {
-      GFile *file;
-      char *uri;
-
-      file = g_file_new_for_commandline_arg (locations[i]);
-      uri = g_file_get_uri (file);
-      g_object_unref (file);
-      res = g_app_info_launch_default_for_uri (uri,
+      char *uri = NULL;
+      char *uri_scheme;
+
+      /* Workaround to handle non-URI locations. We still use the original
+       * location for other cases, because GFile might modify the URI in ways
+       * we don't want. See:
+       * https://bugzilla.gnome.org/show_bug.cgi?id=738690 */
+      uri_scheme = g_uri_parse_scheme (locations[i]);
+      if (!uri_scheme || uri_scheme[0] == '\0')
+        {
+          GFile *file;
+
+          file = g_file_new_for_commandline_arg (locations[i]);
+          uri = g_file_get_uri (file);
+          g_object_unref (file);
+        }
+      g_free (uri_scheme);
+
+      res = g_app_info_launch_default_for_uri (uri ? uri : locations[i],
                                               NULL,
                                               &error);
       g_free (uri);


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