diff options
author | Zander Brown <zbrown@gnome.org> | 2020-05-23 19:24:40 +0100 |
---|---|---|
committer | Zander Brown <zbrown@gnome.org> | 2020-05-23 19:43:12 +0100 |
commit | e7006be27b4a5048470a20079a6762ad4a0d2e18 (patch) | |
tree | f7c9737f8b22a8b5d63e8e134cf91f3a72c16f1a | |
parent | 9b3fd8564c1409aaa325f97dc2723b0a1d15f4e5 (diff) | |
download | gnome-desktop-e7006be27b4a5048470a20079a6762ad4a0d2e18.tar.gz |
thumbnails: keep the orignal file name
Not all mimetypes are based on extension/content, obscuring the filename can break things
Flatpak exposes the original name, can't see it's a problem that a thumbnailer can see it
Fix https://gitlab.gnome.org/GNOME/gnome-desktop/-/issues/154
-rw-r--r-- | libgnome-desktop/gnome-desktop-thumbnail-script.c | 27 |
1 files changed, 6 insertions, 21 deletions
diff --git a/libgnome-desktop/gnome-desktop-thumbnail-script.c b/libgnome-desktop/gnome-desktop-thumbnail-script.c index 0aa26444..6ffbe6d1 100644 --- a/libgnome-desktop/gnome-desktop-thumbnail-script.c +++ b/libgnome-desktop/gnome-desktop-thumbnail-script.c @@ -141,21 +141,6 @@ add_env (GPtrArray *array, NULL); } -static char * -get_extension (const char *path) -{ - g_autofree char *basename = NULL; - char *p; - - basename = g_path_get_basename (path); - p = strrchr (basename, '.'); - if (g_file_test (path, G_FILE_TEST_IS_DIR) || - !p || - p == basename) /* Leading periods on the basename are ignored. */ - return NULL; - return g_strdup (p + 1); -} - #ifdef ENABLE_SECCOMP static gboolean flatpak_fail (GError **error, @@ -784,8 +769,8 @@ script_exec_new (const char *uri, if (exec->sandbox) { char *tmpl; - g_autofree char *ext = NULL; - g_autofree char *infile = NULL; + const char *infile; + g_autofree char *basename = NULL; exec->fd_array = g_array_new (FALSE, TRUE, sizeof (int)); g_array_set_clear_func (exec->fd_array, clear_fd); @@ -799,12 +784,12 @@ script_exec_new (const char *uri, goto bail; } exec->outfile = g_build_filename (exec->outdir, "gnome-desktop-thumbnailer.png", NULL); - ext = get_extension (exec->infile); + basename = g_file_get_basename (file); - if (ext) - infile = g_strdup_printf ("gnome-desktop-file-to-thumbnail.%s", ext); + if (basename) + infile = basename; else - infile = g_strdup_printf ("gnome-desktop-file-to-thumbnail"); + infile = "gnome-desktop-file-to-thumbnail"; exec->infile_tmp = g_build_filename (exec->outdir, infile, NULL); |