[gnome-photos/gnome-3-30] base-item: Don't attempt to load non-UTF-8 paths



commit 8a06a3b59d4799072ece303ade9790008ba8802f
Author: Debarshi Ray <debarshir gnome org>
Date:   Mon Sep 17 20:16:53 2018 +0200

    base-item: Don't attempt to load non-UTF-8 paths
    
    Since, gegl:load insists on UTF-8 encoded paths and it's difficult to
    handle errors from it, validate the path earlier and error out. This
    silences the following WARNING:
      GLib-GObject-WARNING **: 20:13:59.111: value ""/non-UTF-8/path"" of
        type 'gchararray' is invalid or out of range for property 'path'
        of type 'gchararray'
    
    https://gitlab.gnome.org/GNOME/gnome-photos/issues/115

 src/photos-base-item.c | 6 ++++++
 1 file changed, 6 insertions(+)
---
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index 8e170d1c..5541fc8a 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -1476,6 +1476,12 @@ photos_base_item_load_buffer (PhotosBaseItem *self, GCancellable *cancellable, G
   if (path == NULL)
     goto out;
 
+  if (!g_utf8_validate (path, -1, NULL))
+    {
+      g_set_error (error, PHOTOS_ERROR, 0, "Path is not UTF-8 encoded");
+      goto out;
+    }
+
   graph = gegl_node_new ();
   load = gegl_node_new_child (graph, "operation", "gegl:load", "path", path, NULL);
   buffer_sink = gegl_node_new_child (graph, "operation", "gegl:buffer-sink", "buffer", &buffer, NULL);


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