From 4bd35f5349e30b79689238afdfb4bb9585ff884e Mon Sep 17 00:00:00 2001 From: Xan Lopez Date: Mon, 15 Oct 2012 20:24:24 +0200 Subject: ephy-web-view: do not automatically download embedded objects Only download mime types we cannot handle when they belong to the main resource. Prevents us from downloading garbage present in files, among other things. https://bugzilla.gnome.org/show_bug.cgi?id=683635 --- embed/ephy-web-view.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'embed/ephy-web-view.c') diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c index 4f6a7d24e..1aa37f74d 100644 --- a/embed/ephy-web-view.c +++ b/embed/ephy-web-view.c @@ -1814,6 +1814,24 @@ decide_policy_cb (WebKitWebView *web_view, return TRUE; } #else +static gboolean +is_main_resource (WebKitWebFrame *frame, WebKitNetworkRequest *request) +{ + const char *request_uri = NULL, *main_resource_uri = NULL; + WebKitWebDataSource *frame_data_source; + + request_uri = webkit_network_request_get_uri (request); + frame_data_source = webkit_web_frame_get_data_source (frame); + if (frame_data_source) { + WebKitWebResource *resource; + + resource = webkit_web_data_source_get_main_resource (frame_data_source); + main_resource_uri = webkit_web_resource_get_uri (resource); + } + + return g_strcmp0 (request_uri, main_resource_uri) == 0; +} + static gboolean mime_type_policy_decision_requested_cb (WebKitWebView *web_view, WebKitWebFrame *frame, @@ -1852,6 +1870,8 @@ mime_type_policy_decision_requested_cb (WebKitWebView *web_view, /* If WebKit can't handle the mime type start the download process */ should_download = !webkit_web_view_can_show_mime_type (web_view, mime_type); + if (should_download) + should_download = is_main_resource (frame, request); /* FIXME: need to use ephy_file_check_mime if auto-downloading */ if (should_download) { -- cgit v1.2.3