commit 1e5a9f55f01d615e0cc9dd0abdf2b9f7effd4d3a
Author: Frédéric Péters <fpeters@0d.be>
Date:   Sat Sep 19 09:56:11 2009 +0200

    Add back support for the "direction up" navigation (GNOME bug 595653)

diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index 3ef6826..76c987e 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -1643,15 +1643,30 @@ ephy_web_view_set_icon_address (EphyWebView *view,
  * @view: an #EphyWebView
  *
  * Returns whether @view can travel to a higher-level directory on the server.
- * For example, for http://www.example.com/subdir/index.html, returns %TRUE; for
- * http://www.example.com/index.html, returns %FALSE.
+ * For example, for http://www.example.com/subdir/foo.html, returns %TRUE; for
+ * http://www.example.com/, returns %FALSE.
  *
  * Return value: %TRUE if @view can browse to a higher-level directory
  **/
 gboolean
 ephy_web_view_can_go_up (EphyWebView *view)
 {
-  return FALSE;
+  SoupURI *uri;
+  gboolean result;
+
+  uri = soup_uri_new (ephy_web_view_get_address (view));
+  if (uri == NULL)
+    return FALSE;
+
+  if (strcmp (uri->scheme, "about") == 0 || strcmp (uri->scheme, "data") == 0) {
+    soup_uri_free (uri);
+    return FALSE;
+  }
+
+  result = (uri->fragment || uri->query || strlen (uri->path) > 1);
+  soup_uri_free (uri);
+
+  return result;
 }
 
 /**
@@ -2071,7 +2086,54 @@ ephy_web_view_print_preview_navigate (EphyWebView *view,
 GSList *
 ephy_web_view_get_go_up_list (EphyWebView *view)
 {
-  return NULL;
+  SoupURI *uri;
+  GSList *result = NULL;
+  char *t1, *t2;
+
+  uri = soup_uri_new (ephy_web_view_get_address (view));
+  if (uri == NULL)
+    return NULL;
+
+  if (strcmp (uri->scheme, "about") == 0 || strcmp (uri->scheme, "data") == 0) {
+    soup_uri_free (uri);
+    return NULL;
+  }
+
+  /* remove fragment, then query, then go up path */
+  if (uri->fragment) {
+    soup_uri_set_fragment (uri, NULL);
+    result = g_slist_prepend (result, soup_uri_to_string (uri, FALSE));
+  }
+
+  if (uri->query) {
+    soup_uri_set_query (uri, NULL);
+    result = g_slist_prepend (result, soup_uri_to_string (uri, FALSE));
+  }
+
+  if (uri->path[strlen(uri->path)-1] != '/') {
+    /* not a trailing slash, remove "file" part */
+    t1 = strrchr (uri->path, '/');
+    t2 = g_strndup (uri->path, t1-uri->path+1);
+    soup_uri_set_path (uri, t2);
+    g_free (t2);
+    result = g_slist_prepend (result, soup_uri_to_string (uri, FALSE));
+  }
+
+  while (strcmp(uri->path, "/") != 0) {
+    /* chop trailing / */
+    uri->path[strlen (uri->path)-1] = 0;
+    t1 = strrchr (uri->path, '/');
+    t2 = g_strndup (uri->path, t1-uri->path+1);
+    soup_uri_set_path (uri, t2);
+    g_free (t2);
+    result = g_slist_prepend (result, soup_uri_to_string (uri, FALSE));
+  }
+
+  result = g_slist_reverse (result);
+
+  soup_uri_free (uri);
+
+  return result;
 }
 
 /**
diff --git a/src/ephy-navigation-action.c b/src/ephy-navigation-action.c
index bfbae85..972f86d 100644
--- a/src/ephy-navigation-action.c
+++ b/src/ephy-navigation-action.c
@@ -318,6 +318,7 @@ build_up_menu (EphyNavigationAction *action)
 	}
 
 	/* the list data has been consumed */
+	g_slist_foreach (list, (GFunc) g_free, NULL);
 	g_slist_free (list);
 
 	return GTK_WIDGET (menu);
@@ -434,6 +435,7 @@ ephy_navigation_action_activate (GtkAction *gtk_action)
 				up_list->data,
 				NULL,
 				ephy_gui_is_middle_click () ? EPHY_LINK_NEW_TAB : 0);
+		g_slist_foreach (up_list, (GFunc) g_free, NULL);
 		g_slist_free (up_list);
 	}
 }
