mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 06:00:22 +00:00
Bug 541645 – gtkfilechooserdefault segfaults when bookmark does not
2008-07-06 Matthias Clasen <mclasen@redhat.com> Bug 541645 – gtkfilechooserdefault segfaults when bookmark does not contain :// * gtk/gtkfilechooserdefault.c (_gtk_file_chooser_label_for_file): Be more robust. Reported by Jelte van der Hoek svn path=/trunk/; revision=20787
This commit is contained in:
parent
36f5e8d776
commit
128585147f
@ -1,3 +1,11 @@
|
||||
2008-07-06 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
Bug 541645 – gtkfilechooserdefault segfaults when bookmark does not
|
||||
contain ://
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (_gtk_file_chooser_label_for_file):
|
||||
Be more robust. Reported by Jelte van der Hoek
|
||||
|
||||
2008-07-06 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
Bug 540917 – deprecate pack_start_defaults()
|
||||
|
@ -1621,37 +1621,42 @@ _gtk_file_chooser_label_for_file (GFile *file)
|
||||
uri = g_file_get_uri (file);
|
||||
|
||||
start = strstr (uri, "://");
|
||||
start += 3;
|
||||
path = strchr (start, '/');
|
||||
if (start)
|
||||
{
|
||||
start += 3;
|
||||
path = strchr (start, '/');
|
||||
if (path)
|
||||
end = path;
|
||||
else
|
||||
{
|
||||
end = uri + strlen (uri);
|
||||
path = "/";
|
||||
}
|
||||
|
||||
/* strip username */
|
||||
p = strchr (start, '@');
|
||||
if (p && p < end)
|
||||
start = p + 1;
|
||||
|
||||
if (path)
|
||||
end = path;
|
||||
p = strchr (start, ':');
|
||||
if (p && p < end)
|
||||
end = p;
|
||||
|
||||
host = g_strndup (start, end - start);
|
||||
|
||||
/* Translators: the first string is a path and the second string
|
||||
* is a hostname. Nautilus and the panel contain the same string
|
||||
* to translate.
|
||||
*/
|
||||
label = g_strdup_printf (_("%1$s on %2$s"), path, host);
|
||||
|
||||
g_free (host);
|
||||
}
|
||||
else
|
||||
{
|
||||
end = uri + strlen (uri);
|
||||
path = "/";
|
||||
}
|
||||
|
||||
/* strip username */
|
||||
p = strchr (start, '@');
|
||||
if (p && p < end)
|
||||
{
|
||||
start = p + 1;
|
||||
label = g_strdup (uri);
|
||||
}
|
||||
|
||||
p = strchr (start, ':');
|
||||
if (p && p < end)
|
||||
end = p;
|
||||
|
||||
host = g_strndup (start, end - start);
|
||||
|
||||
/* Translators: the first string is a path and the second string
|
||||
* is a hostname. Nautilus and the panel contain the same string
|
||||
* to translate.
|
||||
*/
|
||||
label = g_strdup_printf (_("%1$s on %2$s"), path, host);
|
||||
|
||||
g_free (host);
|
||||
g_free (uri);
|
||||
|
||||
return label;
|
||||
|
Loading…
Reference in New Issue
Block a user