[gvfs/wip/oholy/serial-escape: 1/2] mtp: Fix mounting for devices with special chars in ID_SERIAL



commit d9813df919fd6070c32ebd3922ae6a598b1836c5
Author: Ondrej Holy <oholy redhat com>
Date:   Mon Sep 24 10:25:10 2018 +0200

    mtp: Fix mounting for devices with special chars in ID_SERIAL
    
    ID_SERIAL string is not URI-escaped before use, but unfortunatelly, it
    may contain special characters (e.g. colons) and consequently it is not
    possible to mount affected devices over activation_root. Let's URI-escape
    the ID_SERIAL string before use as URI to fix that issue.
    
    Closes: https://gitlab.gnome.org/GNOME/gvfs/issues/338

 monitor/mtp/gmtpvolumemonitor.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/monitor/mtp/gmtpvolumemonitor.c b/monitor/mtp/gmtpvolumemonitor.c
index d8055f70..3582b994 100644
--- a/monitor/mtp/gmtpvolumemonitor.c
+++ b/monitor/mtp/gmtpvolumemonitor.c
@@ -139,7 +139,7 @@ gudev_add_device (GMtpVolumeMonitor *monitor, GUdevDevice *device, gboolean do_e
   GList *l;
   GMtpVolume *volume;
   const char *usb_serial_id, *device_path;
-  char *uri;
+  char *uri, *usb_serial_id_escaped;
   GFile *activation_mount_root;
   gboolean serial_conflict = FALSE;
 
@@ -160,9 +160,11 @@ gudev_add_device (GMtpVolumeMonitor *monitor, GUdevDevice *device, gboolean do_e
     return;
   }
 
-  uri = g_strdup_printf ("mtp://%s", usb_serial_id);
+  usb_serial_id_escaped = g_uri_escape_string (usb_serial_id, NULL, FALSE);
+  uri = g_strdup_printf ("mtp://%s", usb_serial_id_escaped);
   activation_mount_root = g_file_new_for_uri (uri);
   g_free (uri);
+  g_free (usb_serial_id_escaped);
 
   /*
    * We do not support plugging in multiple devices that lack proper serial


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