From f6b4abc7cacf512e4f8514203c98c090125c0338 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Sun, 16 Nov 2008 18:39:47 +0100 Subject: Prevent displaying './' items --- common/treepathutils.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'common/treepathutils.c') diff --git a/common/treepathutils.c b/common/treepathutils.c index d3ace5a..2e43f94 100644 --- a/common/treepathutils.c +++ b/common/treepathutils.c @@ -119,6 +119,10 @@ void filelist_tree_print(struct PathTree *tree) struct PathTree* filelist_tree_find_node_by_path(struct PathTree *tree, const char *path) { + // remove leading './' + if (strstr(path, "./") == path) path += 2; + + // remove leading and trailing '/' if present char *p; if (IS_DIR_SEP(*path)) p = exclude_trailing_path_sep(path + 1); else p = exclude_trailing_path_sep(path); @@ -282,11 +286,14 @@ gboolean filelist_tree_add_item(struct PathTree *tree, const char *path, const c return FALSE; } - if ((strcmp(path, "/") == 0) || (strcmp(path, ".") == 0) || (strcmp(path, "..") == 0)) { + if ((strcmp(path, "/") == 0) || (strcmp(path, ".") == 0) || (strcmp(path, "..") == 0) || (strcmp(path, "./") == 0)) { fprintf(stderr, "filelist_tree_add_item: path '%s' is not a valid path\n", path); return FALSE; } + // remove leading './' + if (strstr(path, "./") == path) path += 2; + // remove leading and trailing '/' if present char *p; if (IS_DIR_SEP(*path)) p = exclude_trailing_path_sep(path + 1); -- cgit v1.2.3