From 182e12aed96d302f78f52c16b52b8f3c2784d415 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Campos Date: Tue, 11 May 2010 12:29:56 +0000 Subject: [shell] Fix opening files with '#' in its name See bug #616515. --- (limited to 'shell') diff --git a/shell/main.c b/shell/main.c index d7d6e15..187a794 100644 --- a/shell/main.c +++ b/shell/main.c @@ -146,6 +146,28 @@ launch_previewer (void) return retval; } +static gchar * +get_label_from_filename (const gchar *filename) +{ + GFile *file; + gchar *label; + gboolean exists; + + label = g_strrstr (filename, "#"); + if (!label) + return NULL; + + /* Filename contains a #, check + * whether it's part of the path + * or a label + */ + file = g_file_new_for_commandline_arg (filename); + exists = g_file_query_exists (file, NULL); + g_object_unref (file); + + return exists ? NULL : label; +} + static void load_files (const char **files) { @@ -179,7 +201,7 @@ load_files (const char **files) const gchar *app_uri; filename = files[i]; - label = strchr (filename, '#'); + label = get_label_from_filename (filename); if (label) { *label = 0; label++; -- cgit v0.9.1