From 896c3d1b2cff1b73b6634ab66672fe5df81a5749 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Tue, 3 Mar 2009 19:02:16 +0000 Subject: [PATCH] =?utf8?q?Bug=20561172=20=E2=80=93=20gnome-open=20fails=20?= =?utf8?q?on=20local=20URIs=20with=20anchors?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 2009-03-03 Alexander Larsson Bug 561172 – gnome-open fails on local URIs with anchors * gdesktopappinfo.c: Don't force uris to filenames if the uri has an anchor, because that would strip the anchor. * glocalvfs.c: Strip anchor from file:// uris when creating GFile, since g_filename_from_uri doesn't handle them. svn path=/trunk/; revision=7953 --- gio/ChangeLog | 12 ++++++++++++ gio/gdesktopappinfo.c | 24 ++++++++++++++++-------- gio/glocalvfs.c | 18 ++++++++++++++++-- 3 files changed, 44 insertions(+), 10 deletions(-) diff --git a/gio/ChangeLog b/gio/ChangeLog index d3fb320..594f71e 100644 --- a/gio/ChangeLog +++ b/gio/ChangeLog @@ -1,5 +1,17 @@ 2009-03-03 Alexander Larsson + Bug 561172 – gnome-open fails on local URIs with anchors + + * gdesktopappinfo.c: + Don't force uris to filenames if the uri has an anchor, because + that would strip the anchor. + + * glocalvfs.c: + Strip anchor from file:// uris when creating GFile, since + g_filename_from_uri doesn't handle them. + +2009-03-03 Alexander Larsson + Bug 562613 – Missing const modifier in string parameters * gfileinputstream.[ch]: diff --git a/gio/gdesktopappinfo.c b/gio/gdesktopappinfo.c index ffe1bde..fcd7737 100644 --- a/gio/gdesktopappinfo.c +++ b/gio/gdesktopappinfo.c @@ -567,6 +567,7 @@ expand_macro (char macro, char *expanded; gboolean force_file_uri; char force_file_uri_macro; + char *uri; g_return_if_fail (exec != NULL); @@ -602,15 +603,18 @@ expand_macro (char macro, case 'n': if (uris) { - if (!force_file_uri) + uri = uris->data; + if (!force_file_uri || + /* Pass URI if it contains an anchor */ + strchr (uri, '#') != NULL) { - expanded = expand_macro_single (macro, uris->data); + expanded = expand_macro_single (macro, uri); } else { - expanded = expand_macro_single (force_file_uri_macro, uris->data); + expanded = expand_macro_single (force_file_uri_macro, uri); if (expanded == NULL) - expanded = expand_macro_single (macro, uris->data); + expanded = expand_macro_single (macro, uri); } if (expanded) @@ -629,15 +633,19 @@ expand_macro (char macro, case 'N': while (uris) { - if (!force_file_uri) + uri = uris->data; + + if (!force_file_uri || + /* Pass URI if it contains an anchor */ + strchr (uri, '#') != NULL) { - expanded = expand_macro_single (macro, uris->data); + expanded = expand_macro_single (macro, uri); } else { - expanded = expand_macro_single (force_file_uri_macro, uris->data); + expanded = expand_macro_single (force_file_uri_macro, uri); if (expanded == NULL) - expanded = expand_macro_single (macro, uris->data); + expanded = expand_macro_single (macro, uri); } if (expanded) diff --git a/gio/glocalvfs.c b/gio/glocalvfs.c index 980e1cf..cd535e3 100644 --- a/gio/glocalvfs.c +++ b/gio/glocalvfs.c @@ -31,6 +31,7 @@ #ifdef HAVE_PWD_H #include #endif +#include #include "gioalias.h" @@ -90,9 +91,22 @@ g_local_vfs_get_file_for_uri (GVfs *vfs, { char *path; GFile *file; + char *stripped_uri, *hash; + + if (strchr (uri, '#') != NULL) + { + stripped_uri = g_strdup (uri); + hash = strchr (stripped_uri, '#'); + *hash = 0; + } + else + stripped_uri = (char *)uri; + + path = g_filename_from_uri (stripped_uri, NULL, NULL); - path = g_filename_from_uri (uri, NULL, NULL); - + if (stripped_uri != uri) + g_free (stripped_uri); + if (path != NULL) file = _g_local_file_new (path); else -- 2.7.4