[evolution] Bug 673895 - "Send To..." doesn't work anymore



commit e3295b4d11bca23980472f1d54f4a52927c41539
Author: Matthew Barnes <mbarnes redhat com>
Date:   Wed Apr 11 09:40:54 2012 -0400

    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 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index 39edcdb..5c91037 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;
 }



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