diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2006-02-07 02:37:18 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2006-02-07 02:37:18 +0800 |
commit | a8f6314cab310543ead2f0e48cd936996425dd6b (patch) | |
tree | 64eb44be07a2d6c7fc46adfb357858a58427ec3c /src/ephy-main.c | |
parent | f69428538cf9049e4bc6dab1106e036c0c3c4f8c (diff) | |
download | gsoc2013-epiphany-a8f6314cab310543ead2f0e48cd936996425dd6b.tar gsoc2013-epiphany-a8f6314cab310543ead2f0e48cd936996425dd6b.tar.gz gsoc2013-epiphany-a8f6314cab310543ead2f0e48cd936996425dd6b.tar.bz2 gsoc2013-epiphany-a8f6314cab310543ead2f0e48cd936996425dd6b.tar.lz gsoc2013-epiphany-a8f6314cab310543ead2f0e48cd936996425dd6b.tar.xz gsoc2013-epiphany-a8f6314cab310543ead2f0e48cd936996425dd6b.tar.zst gsoc2013-epiphany-a8f6314cab310543ead2f0e48cd936996425dd6b.zip |
Fix handling of non-ascii extra arguments.
2006-02-06 Christian Persch <chpe@cvs.gnome.org>
* src/ephy-main.c: (main):
Fix handling of non-ascii extra arguments.
Diffstat (limited to 'src/ephy-main.c')
-rw-r--r-- | src/ephy-main.c | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/src/ephy-main.c b/src/ephy-main.c index a3d7f7f5d..1708b6272 100644 --- a/src/ephy-main.c +++ b/src/ephy-main.c @@ -86,7 +86,7 @@ static const GOptionEntry option_entries[] = N_("Load the given session file"), N_("FILE") }, { "add-bookmark", 't', 0, G_OPTION_ARG_STRING, &bookmark_url, N_("Add a bookmark"), N_("URL") }, - { G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &arguments, + { G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_FILENAME_ARRAY, &arguments, "", "" }, { NULL } }; @@ -555,19 +555,44 @@ main (int argc, for (i = 0; arguments[i] != NULL; ++i) { - char *path = NULL; + char *uri, *path = NULL; path = realpath (arguments[i], NULL); if (path != NULL) { - g_free (arguments[i]); - arguments[i] = g_strdup (path); + uri = g_locale_to_utf8 (path, -1, + NULL, NULL, &error); free (path); } - /* FIXME: I'd use gnome_vfs_make_uri_from_shell_arg - * but then "epiphany www.gnome.org" would try to open - * a local file, not a web address. - */ + else + { + uri = g_locale_to_utf8 (arguments[i], -1, + NULL, NULL, &error); + } + + if (uri != NULL) + { + g_free (arguments[i]); + + /* If it's a file, use gnome_vfs_make_uri_from_shell_arg, + * so we get the right escaping. + */ + if (path != NULL) + { + arguments[i] = gnome_vfs_make_uri_from_shell_arg (uri); + } + else + { + arguments[i] = uri; + } + } + else + { + g_print ("Could not convert '%s' to UTF-8: %s!\n", + arguments[i], error->message); + g_error_free (error); + exit (1); + } } } |