From 9b8959a4de1dc5eacdf807ae6d311defce4fad51 Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Fri, 31 Dec 2004 16:09:40 +0000 Subject: Move mime permission checks to ephy-file-helpers. 2004-12-31 Christian Persch * embed/ephy-embed-shell.c: (ephy_embed_shell_finalize), (ephy_embed_shell_get_encodings): * embed/ephy-embed-shell.h: * embed/mozilla/ContentHandler.cpp: * embed/mozilla/ContentHandler.h: * lib/ephy-file-helpers.c: (ephy_file_helpers_shutdown), (ephy_file_delete_on_exit), (load_mime_from_xml), (ephy_file_check_mime): * lib/ephy-file-helpers.h: Move mime permission checks to ephy-file-helpers. * src/popup-commands.c: (image_open_uri), (save_source_completed_cb), (popup_cmd_open_image): Only open the image if its mime type is 'safe'. --- src/popup-commands.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/popup-commands.c') diff --git a/src/popup-commands.c b/src/popup-commands.c index fd7805034..4804b3316 100644 --- a/src/popup-commands.c +++ b/src/popup-commands.c @@ -365,7 +365,8 @@ popup_cmd_open_frame (GtkAction *action, } static void -image_open_uri (const char *address) +image_open_uri (const char *address, + gboolean delete) { GList *uris = NULL; char *canonical; @@ -380,7 +381,8 @@ image_open_uri (const char *address) GNOME_VFS_FILE_INFO_FORCE_SLOW_MIME_TYPE) == GNOME_VFS_OK && (info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_MIME_TYPE) && info->mime_type != NULL && - info->mime_type[0] != '\0') + info->mime_type[0] != '\0' && + ephy_file_check_mime (info->mime_type) == EPHY_MIME_PERMISSION_SAFE) { app = gnome_vfs_mime_get_default_application (info->mime_type); } @@ -392,12 +394,20 @@ image_open_uri (const char *address) gnome_vfs_mime_application_launch (app, uris); gnome_vfs_mime_application_free (app); g_list_free (uris); + if (delete) + { + ephy_file_delete_on_exit (address); + } } else { /* FIXME We should really warn the user here */ g_warning ("Cannot find an application to open %s with.", address); + if (delete) + { + gnome_vfs_unlink (address); + } } g_free (canonical); @@ -412,9 +422,7 @@ save_source_completed_cb (EphyEmbedPersist *persist) dest = ephy_embed_persist_get_dest (persist); g_return_if_fail (dest != NULL); - ephy_file_delete_on_exit (dest); - - image_open_uri (dest); + image_open_uri (dest, TRUE); } static void @@ -475,7 +483,7 @@ popup_cmd_open_image (GtkAction *action, if (strcmp (scheme, "file") == 0) { - image_open_uri (address); + image_open_uri (address, FALSE); } else { -- cgit v1.2.3