summaryrefslogtreecommitdiff
path: root/monitor
diff options
context:
space:
mode:
authorOndrej Holy <oholy@redhat.com>2018-09-24 10:37:51 +0200
committerOndrej Holy <oholy@redhat.com>2018-09-24 10:40:24 +0200
commit55376c3e5756c531d6d44defb661f58df6aa8cde (patch)
tree1eacfb552b7a6d7f85d1b5bb3b23570a6ec5416f /monitor
parent4a4b22ece7d48f96da9120d677b2707a541263d5 (diff)
downloadgvfs-55376c3e5756c531d6d44defb661f58df6aa8cde.tar.gz
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.
Diffstat (limited to 'monitor')
-rw-r--r--monitor/gphoto2/ggphoto2volumemonitor.c11
1 files 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