diff options
author | Xan Lopez <xan@igalia.com> | 2012-10-16 02:24:24 +0800 |
---|---|---|
committer | Xan Lopez <xan@igalia.com> | 2012-10-16 02:30:35 +0800 |
commit | 845fdfc675220fcbf257d13129f386946a89cb52 (patch) | |
tree | 1fb2e66b12032486bd556af9e3229721652000d1 | |
parent | 09c7c90335289f2943bbc4c1f34e217b20c41d40 (diff) | |
download | gsoc2013-epiphany-845fdfc675220fcbf257d13129f386946a89cb52.tar.gz gsoc2013-epiphany-845fdfc675220fcbf257d13129f386946a89cb52.tar.zst gsoc2013-epiphany-845fdfc675220fcbf257d13129f386946a89cb52.zip |
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 <object>
files, among other things.
https://bugzilla.gnome.org/show_bug.cgi?id=683635
-rw-r--r-- | embed/ephy-web-view.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c index 9774f87ae..a1331b011 100644 --- a/embed/ephy-web-view.c +++ b/embed/ephy-web-view.c @@ -1814,6 +1814,24 @@ decide_policy_cb (WebKitWebView *web_view, } #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, WebKitNetworkRequest *request, @@ -1851,6 +1869,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) { |