Index: exo/exo-url.c =================================================================== --- exo/exo-url.c (revision 28835) +++ exo/exo-url.c (working copy) @@ -140,35 +140,51 @@ static gchar* -_exo_url_to_local_path (const gchar *url) +_exo_url_to_local_path (const gchar *url, gchar **anchor) { gchar *current_dir; gchar *path; - + gchar *no_anchor_url = NULL; + + if (anchor) + *anchor = NULL; + if (g_strrstr(url, "#") != NULL) { + no_anchor_url = g_strdup(url); + *anchor = g_strdup(g_strrstr(url, "#")); + *(g_strrstr(no_anchor_url, "#")) = '\0'; + } else { + no_anchor_url = g_strdup(url); + } + /* transform a file:-URI to a local path */ - path = g_filename_from_uri (url, NULL, NULL); + path = g_filename_from_uri (no_anchor_url, NULL, NULL); + if (G_LIKELY (path == NULL)) { - /* check if url is an absolute path */ - if (g_path_is_absolute (url)) + /* check if no_anchor_url is an absolute path */ + if (g_path_is_absolute (no_anchor_url)) { /* well, we got our path then */ - path = g_strdup (url); + path = g_strdup (no_anchor_url); } else { /* treat it like a relative path */ current_dir = g_get_current_dir (); - path = g_build_filename (current_dir, url, NULL); + path = g_build_filename (current_dir, no_anchor_url, NULL); g_free (current_dir); } } + g_free(no_anchor_url); + /* verify that a file of the given name exists */ if (!g_file_test (path, G_FILE_TEST_EXISTS)) { /* no local path then! */ g_free (path); + g_free (*anchor); + *anchor = NULL; path = NULL; } @@ -209,6 +225,7 @@ gchar *uri; gchar *quoted_url; gint status; + gchar *anchor = NULL; g_return_val_if_fail (url != NULL, FALSE); g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE); @@ -220,7 +237,7 @@ _exo_i18n_init (); /* try to conver the URL into a local path */ - local_path = _exo_url_to_local_path (url); + local_path = _exo_url_to_local_path (url, &anchor); /* now, let's see what we have here */ if (local_path != NULL) @@ -234,7 +251,14 @@ || fnmatch ("*.html", local_path, FNM_CASEFOLD) == 0) { /* transform the path to a file:-URI */ - uri = g_filename_to_uri (local_path, NULL, error); + if (G_UNLIKELY (anchor != NULL)) { + gchar *tmp = g_filename_to_uri (local_path, NULL, error); + uri = g_strconcat(tmp, anchor, NULL); + g_free(tmp); + g_free(anchor); + } else { + uri = g_filename_to_uri (local_path, NULL, error); + } if (G_LIKELY (uri != NULL)) { /* try to execute the file:-URI in a web browser */