diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2005-01-01 00:09:40 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2005-01-01 00:09:40 +0800 |
commit | 9b8959a4de1dc5eacdf807ae6d311defce4fad51 (patch) | |
tree | 88ac3f23c1b1024b3b6d7101bbc6712ebd943e74 /embed/ephy-embed-shell.c | |
parent | ddf12994065314b103f57969640845d7344974f2 (diff) | |
download | gsoc2013-epiphany-9b8959a4de1dc5eacdf807ae6d311defce4fad51.tar gsoc2013-epiphany-9b8959a4de1dc5eacdf807ae6d311defce4fad51.tar.gz gsoc2013-epiphany-9b8959a4de1dc5eacdf807ae6d311defce4fad51.tar.bz2 gsoc2013-epiphany-9b8959a4de1dc5eacdf807ae6d311defce4fad51.tar.lz gsoc2013-epiphany-9b8959a4de1dc5eacdf807ae6d311defce4fad51.tar.xz gsoc2013-epiphany-9b8959a4de1dc5eacdf807ae6d311defce4fad51.tar.zst gsoc2013-epiphany-9b8959a4de1dc5eacdf807ae6d311defce4fad51.zip |
Move mime permission checks to ephy-file-helpers.
2004-12-31 Christian Persch <chpe@cvs.gnome.org>
* 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'.
Diffstat (limited to 'embed/ephy-embed-shell.c')
-rw-r--r-- | embed/ephy-embed-shell.c | 94 |
1 files changed, 1 insertions, 93 deletions
diff --git a/embed/ephy-embed-shell.c b/embed/ephy-embed-shell.c index 0051be195..4802438a0 100644 --- a/embed/ephy-embed-shell.c +++ b/embed/ephy-embed-shell.c @@ -32,19 +32,15 @@ #include "ephy-encodings.h" #include "ephy-debug.h" -#include <libxml/xmlreader.h> -#include <string.h> - #define EPHY_EMBED_SHELL_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_EMBED_SHELL, EphyEmbedShellPrivate)) -struct EphyEmbedShellPrivate +struct _EphyEmbedShellPrivate { EphyHistory *global_history; DownloaderView *downloader_view; EphyFaviconCache *favicon_cache; EphyEmbedSingle *embed_single; EphyEncodings *encodings; - GHashTable *mime_table; }; static void ephy_embed_shell_class_init (EphyEmbedShellClass *klass); @@ -120,12 +116,6 @@ ephy_embed_shell_finalize (GObject *object) g_object_unref (G_OBJECT (shell->priv->embed_single)); } - LOG ("Destroying mime type hashtable") - if (shell->priv->mime_table) - { - g_hash_table_destroy (shell->priv->mime_table); - } - G_OBJECT_CLASS (parent_class)->finalize (object); } @@ -207,88 +197,6 @@ ephy_embed_shell_get_encodings (EphyEmbedShell *shell) } static void -load_mime_from_xml (EphyEmbedShell *shell) -{ - xmlTextReaderPtr reader; - const char *xml_file; - int ret; - EphyMimePermission permission = EPHY_MIME_PERMISSION_UNKNOWN; - - xml_file = ephy_file ("mime-types-permissions.xml"); - if (xml_file == NULL) - { - g_warning ("MIME types permissions file not found!\n"); - return; - } - - reader = xmlNewTextReaderFilename (xml_file); - if (reader == NULL) - { - g_warning ("Could not load MIME types permissions file!\n"); - return; - } - - ret = xmlTextReaderRead (reader); - while (ret == 1) - { - const xmlChar *tag; - xmlReaderTypes type; - - tag = xmlTextReaderConstName (reader); - type = xmlTextReaderNodeType (reader); - - if (xmlStrEqual (tag, "safe") && type == XML_READER_TYPE_ELEMENT) - { - permission = EPHY_MIME_PERMISSION_SAFE; - } - else if (xmlStrEqual (tag, "unsafe") && type == XML_READER_TYPE_ELEMENT) - { - permission = EPHY_MIME_PERMISSION_UNSAFE; - } - else if (xmlStrEqual (tag, "mime-type")) - { - xmlChar *type; - - type = xmlTextReaderGetAttribute (reader, "type"); - g_hash_table_insert (shell->priv->mime_table, - type, GINT_TO_POINTER (permission)); - } - - ret = xmlTextReaderRead (reader); - } - - xmlFreeTextReader (reader); -} - -EphyMimePermission -ephy_embed_shell_check_mime (EphyEmbedShell *shell, const char *mime_type) -{ - EphyMimePermission permission; - gpointer tmp; - - g_return_val_if_fail (EPHY_IS_EMBED_SHELL (shell), EPHY_MIME_PERMISSION_UNKNOWN); - - if (shell->priv->mime_table == NULL) - { - shell->priv->mime_table = g_hash_table_new_full - (g_str_hash, g_str_equal, xmlFree, NULL); - load_mime_from_xml (shell); - } - - tmp = g_hash_table_lookup (shell->priv->mime_table, mime_type); - if (tmp == NULL) - { - permission = EPHY_MIME_PERMISSION_UNKNOWN; - } - else - { - permission = GPOINTER_TO_INT (tmp); - } - - return permission; -} - -static void ephy_embed_shell_init (EphyEmbedShell *shell) { shell->priv = EPHY_EMBED_SHELL_GET_PRIVATE (shell); |