epiphany r8002 - trunk/embed
- From: jensg svn gnome org
- To: svn-commits-list gnome org
- Subject: epiphany r8002 - trunk/embed
- Date: Thu, 28 Feb 2008 22:13:50 +0000 (GMT)
Author: jensg
Date: Thu Feb 28 22:13:49 2008
New Revision: 8002
URL: http://svn.gnome.org/viewvc/epiphany?rev=8002&view=rev
Log:
Strip anchors from URIs before trying to turn them into a GFile, and properly
handle get_file_info failing. Fixes a crash when using URLs like
file:///path#anchor. Bug #519370.
Modified:
trunk/embed/ephy-base-embed.c
Modified: trunk/embed/ephy-base-embed.c
==============================================================================
--- trunk/embed/ephy-base-embed.c (original)
+++ trunk/embed/ephy-base-embed.c Thu Feb 28 22:13:49 2008
@@ -1372,6 +1372,8 @@
{
EphyBaseEmbedPrivate *priv = embed->priv;
gboolean local;
+ gchar *anchor;
+ gchar *url;
GFile *file;
GFileType file_type;
GFileInfo *file_info;
@@ -1388,11 +1390,25 @@
local = g_str_has_prefix (address, "file://");
if (local == FALSE) return;
-
- file = g_file_new_for_uri (address);
+
+ /* strip off anchors */
+ anchor = strchr (address, '#');
+ if (anchor != NULL) {
+ url = g_strndup (address, anchor - address);
+ } else {
+ url = g_strdup (address);
+ }
+
+ file = g_file_new_for_uri (url);
file_info = g_file_query_info (file,
G_FILE_ATTRIBUTE_STANDARD_TYPE,
0, NULL, NULL);
+ if (file_info == NULL) {
+ g_object_unref (file);
+ g_free (url);
+ return;
+ }
+
file_type = g_file_info_get_file_type (file_info);
g_object_unref (file_info);
@@ -1402,7 +1418,7 @@
G_CALLBACK (ephy_base_embed_file_monitor_cb),
embed);
priv->monitor_directory = TRUE;
- LOG ("Installed monitor for directory '%s'", address);
+ LOG ("Installed monitor for directory '%s'", url);
}
else if (file_type == G_FILE_TYPE_REGULAR) {
monitor = g_file_monitor_file (file, 0, NULL, NULL);
@@ -1410,10 +1426,11 @@
G_CALLBACK (ephy_base_embed_file_monitor_cb),
embed);
priv->monitor_directory = FALSE;
- LOG ("Installed monitor for file '%s'", address);
+ LOG ("Installed monitor for file '%s'", url);
}
priv->monitor = monitor;
g_object_unref (file);
+ g_free (url);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]