From c7a5a8dfb5379995af90b819fcffe2b8dad0ab7b Mon Sep 17 00:00:00 2001 From: Nick Schermer <nick@xfce.org> Date: Wed, 7 Nov 2012 20:28:02 +0100 Subject: [PATCH] Improve generating remote display names (bug #9442). Be safer with port numbers and such. --- thunar/thunar-gio-extensions.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/thunar/thunar-gio-extensions.c b/thunar/thunar-gio-extensions.c index 1fd3bef6d..b4da6840c 100644 --- a/thunar/thunar-gio-extensions.c +++ b/thunar/thunar-gio-extensions.c @@ -267,7 +267,8 @@ thunar_g_file_get_display_name_remote (GFile *mount_point) gchar *hostname; gchar *display_name = NULL; const gchar *skip; - const gchar skip_chars[] = G_URI_RESERVED_CHARS_ALLOWED_IN_PATH_ELEMENT; + const gchar *firstdot; + const gchar skip_chars[] = ":@"; guint n; _thunar_return_val_if_fail (G_IS_FILE (mount_point), NULL); @@ -287,13 +288,19 @@ thunar_g_file_get_display_name_remote (GFile *mount_point) /* goto path part */ path = strchr (p, '/'); + firstdot = strchr (p, '.'); - /* skip password or login names in the hostname */ - for (n = 0; n < G_N_ELEMENTS (skip_chars) - 1; n++) + if (firstdot != NULL) { - skip = strchr (p, skip_chars[n]); - if (skip != NULL && (path == NULL || skip < path)) - p = skip + 1; + /* skip password or login names in the hostname */ + for (n = 0; n < G_N_ELEMENTS (skip_chars) - 1; n++) + { + skip = strchr (p, skip_chars[n]); + if (skip != NULL + && (path == NULL || skip < path) + && (skip < firstdot)) + p = skip + 1; + } } /* extract the path and hostname from the string */ -- GitLab