From f0a1e9035be1462916121fd9df821edbbf72170d Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Sat, 19 Feb 2000 14:18:51 +0000 Subject: [PATCH] r196: Collection widget passes on unused Escape key press events. Checks for copying/moving things into themselves now use the realpath(). --- ROX-Filer/src/action.c | 35 ++++++++++++++++++++++++----------- ROX-Filer/src/collection.c | 2 ++ 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/ROX-Filer/src/action.c b/ROX-Filer/src/action.c index 79cc8147..b5fbee00 100644 --- a/ROX-Filer/src/action.c +++ b/ROX-Filer/src/action.c @@ -247,20 +247,35 @@ static char *action_auto_quiet(char *data) /* SUPPORT */ -/* TRUE iff `sub' is (or would be) an object inside the directory `parent' */ +/* TRUE iff `sub' is (or would be) an object inside the directory `parent', + * (or the two are the same directory) + */ static gboolean is_sub_dir(char *sub, char *parent) { - int parent_len; + int parent_len; + guchar *real_sub, *real_parent; + gboolean retval; - parent_len = strlen(parent); - if (strncmp(parent, sub, parent_len)) - return FALSE; + real_sub = pathdup(sub); + real_parent = pathdup(parent); + + parent_len = strlen(real_parent); + if (strncmp(real_parent, real_sub, parent_len)) + retval = FALSE; + else + { + /* real_sub is at least as long as real_parent and all + * characters upto real_parent's length match. + */ - /* sub is at least as long as parent and all characters upto - * parent's length match. - */ + retval = real_sub[parent_len] == 0 + || real_sub[parent_len] == '/'; + } - return sub[parent_len] == 0 || sub[parent_len] == '/'; + g_free(real_sub); + g_free(real_parent); + + return retval; } static gboolean display_dir(gpointer data) @@ -964,7 +979,6 @@ static gboolean do_copy2(char *path, char *dest) /* Copy path to dest. * Check that path not copied into itself. - * path and dest are real paths (coming from the filer) */ static gboolean do_copy(char *path, char *dest) { @@ -980,7 +994,6 @@ static gboolean do_copy(char *path, char *dest) /* Move path to dest. * Check that path not moved into itself. - * path and dest are real paths (coming from the filer) */ static gboolean do_move(char *path, char *dest) { diff --git a/ROX-Filer/src/collection.c b/ROX-Filer/src/collection.c index 6529fde3..22737dcb 100644 --- a/ROX-Filer/src/collection.c +++ b/ROX-Filer/src/collection.c @@ -937,6 +937,8 @@ static gint collection_key_press(GtkWidget *widget, GdkEventKey *event) return_pressed(collection); break; case GDK_Escape: + if (!collection->target_cb) + return FALSE; /* Pass it on */ collection_target(collection, NULL, NULL); break; case ' ': -- 2.11.4.GIT