From e3295b4d11bca23980472f1d54f4a52927c41539 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Wed, 11 Apr 2012 09:40:54 -0400 Subject: Bug 673895 - "Send To..." doesn't work anymore Our hidden file/directory blacklist went a little too far. Evolution was blacklisting its own temporary files. This changes the blacklist function to trust the user's own XDG Base Directories. --- composer/e-msg-composer.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index 39edcdba43..5c91037fa6 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -3928,12 +3928,23 @@ merge_always_cc_and_bcc (EComposerHeaderTable *table, static const gchar *blacklist[] = { ".", "etc", ".." }; static gboolean -file_is_blacklisted (gchar *filename) +file_is_blacklisted (const gchar *argument) { + GFile *file; gboolean blacklisted = FALSE; guint ii, jj, n_parts; + gchar *filename; gchar **parts; + /* The "attach" argument may be a URI or local path. Normalize + * it to a local path if we can. We only blacklist local files. */ + file = g_file_new_for_commandline_arg (argument); + filename = g_file_get_path (file); + g_object_unref (file); + + if (filename == NULL) + return FALSE; + parts = g_strsplit (filename, G_DIR_SEPARATOR_S, -1); n_parts = g_strv_length (parts); @@ -3946,7 +3957,18 @@ file_is_blacklisted (gchar *filename) } } + if (blacklisted) { + /* Don't blacklist files in trusted base directories. */ + if (g_str_has_prefix (filename, g_get_user_data_dir ())) + blacklisted = FALSE; + if (g_str_has_prefix (filename, g_get_user_cache_dir ())) + blacklisted = FALSE; + if (g_str_has_prefix (filename, g_get_user_config_dir ())) + blacklisted = FALSE; + } + g_strfreev (parts); + g_free (filename); return blacklisted; } -- cgit v1.2.3