diff options
author | Jens Granseuer <jensg@src.gnome.org> | 2008-02-29 06:13:49 +0800 |
---|---|---|
committer | Jens Granseuer <jensg@src.gnome.org> | 2008-02-29 06:13:49 +0800 |
commit | 95918bcefecf6f1454273751c6a908563356085f (patch) | |
tree | a9bfc8eadcb4ce0bac8acce9f90988be755febdb /embed | |
parent | 2a59317dbd2fe3be837263157e84e3a0e01707d5 (diff) | |
download | gsoc2013-epiphany-95918bcefecf6f1454273751c6a908563356085f.tar gsoc2013-epiphany-95918bcefecf6f1454273751c6a908563356085f.tar.gz gsoc2013-epiphany-95918bcefecf6f1454273751c6a908563356085f.tar.bz2 gsoc2013-epiphany-95918bcefecf6f1454273751c6a908563356085f.tar.lz gsoc2013-epiphany-95918bcefecf6f1454273751c6a908563356085f.tar.xz gsoc2013-epiphany-95918bcefecf6f1454273751c6a908563356085f.tar.zst gsoc2013-epiphany-95918bcefecf6f1454273751c6a908563356085f.zip |
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.
svn path=/trunk/; revision=8002
Diffstat (limited to 'embed')
-rw-r--r-- | embed/ephy-base-embed.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/embed/ephy-base-embed.c b/embed/ephy-base-embed.c index 802f8c15e..5c2f506e5 100644 --- a/embed/ephy-base-embed.c +++ b/embed/ephy-base-embed.c @@ -1372,6 +1372,8 @@ ephy_base_embed_update_file_monitor (EphyBaseEmbed *embed, { EphyBaseEmbedPrivate *priv = embed->priv; gboolean local; + gchar *anchor; + gchar *url; GFile *file; GFileType file_type; GFileInfo *file_info; @@ -1388,11 +1390,25 @@ ephy_base_embed_update_file_monitor (EphyBaseEmbed *embed, 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 @@ ephy_base_embed_update_file_monitor (EphyBaseEmbed *embed, 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 @@ ephy_base_embed_update_file_monitor (EphyBaseEmbed *embed, 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 |