[gvfs/gnome-3-30] gphoto2: Fix mounting for devices with special chars in ID_SERIAL
- From: Ondrej Holy <oholy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs/gnome-3-30] gphoto2: Fix mounting for devices with special chars in ID_SERIAL
- Date: Mon, 24 Sep 2018 15:27:24 +0000 (UTC)
commit 7152c16756267e5d6a8e9f559154d2380a3ca1f7
Author: Ondrej Holy <oholy redhat com>
Date: Mon Sep 24 10:37:51 2018 +0200
gphoto2: Fix mounting for devices with special chars in ID_SERIAL
ID_SERIAL string is not URI-escaped before use, but unfortunately, 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.
monitor/gphoto2/ggphoto2volumemonitor.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/monitor/gphoto2/ggphoto2volumemonitor.c b/monitor/gphoto2/ggphoto2volumemonitor.c
index 6bd9fc8b..54dec6e8 100644
--- a/monitor/gphoto2/ggphoto2volumemonitor.c
+++ b/monitor/gphoto2/ggphoto2volumemonitor.c
@@ -140,7 +140,7 @@ gudev_add_camera (GGPhoto2VolumeMonitor *monitor, GUdevDevice *device, gboolean
GList *store_heads, *l;
guint num_store_heads;
const char *usb_bus_num, *usb_device_num, *usb_serial_id, *device_path;
- gchar *prefix;
+ gchar *prefix, *usb_serial_id_escaped;
GFile *mount_prefix;
gboolean serial_conflict = FALSE;
@@ -185,7 +185,8 @@ gudev_add_camera (GGPhoto2VolumeMonitor *monitor, GUdevDevice *device, gboolean
return;
}
- prefix = g_strdup_printf ("gphoto2://%s", usb_serial_id);
+ usb_serial_id_escaped = g_uri_escape_string (usb_serial_id, NULL, FALSE);
+ prefix = g_strdup_printf ("gphoto2://%s", usb_serial_id_escaped);
mount_prefix = g_file_new_for_uri (prefix);
g_free (prefix);
@@ -218,6 +219,7 @@ gudev_add_camera (GGPhoto2VolumeMonitor *monitor, GUdevDevice *device, gboolean
g_warning ("device %s has an identical ID_SERIAL value to an "
"existing device. Multiple devices are not supported.",
g_udev_device_get_device_file (device));
+ g_free (usb_serial_id_escaped);
return;
}
@@ -239,11 +241,11 @@ gudev_add_camera (GGPhoto2VolumeMonitor *monitor, GUdevDevice *device, gboolean
*/
if (num_store_heads == 1)
{
- uri = g_strdup_printf ("gphoto2://%s", usb_serial_id);
+ uri = g_strdup_printf ("gphoto2://%s", usb_serial_id_escaped);
}
else
{
- uri = g_strdup_printf ("gphoto2://%s/%s", usb_serial_id,
+ uri = g_strdup_printf ("gphoto2://%s/%s", usb_serial_id_escaped,
store_path[0] == '/' ? store_path + 1 : store_path);
}
g_debug ("gudev_add_camera: ... adding URI for storage head: %s", uri);
@@ -266,6 +268,7 @@ gudev_add_camera (GGPhoto2VolumeMonitor *monitor, GUdevDevice *device, gboolean
}
g_list_free_full (store_heads, g_free);
+ g_free (usb_serial_id_escaped);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]