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:24:24 +0800 |
commit | 4bd35f5349e30b79689238afdfb4bb9585ff884e (patch) | |
tree | 6b992722a2be9b840671d859136cbec119c9bd88 /embed/ephy-web-view.c | |
parent | 79d61564bd8e122dfd5ee80ce37672f6d437efff (diff) | |
download | gsoc2013-epiphany-4bd35f5349e30b79689238afdfb4bb9585ff884e.tar gsoc2013-epiphany-4bd35f5349e30b79689238afdfb4bb9585ff884e.tar.gz gsoc2013-epiphany-4bd35f5349e30b79689238afdfb4bb9585ff884e.tar.bz2 gsoc2013-epiphany-4bd35f5349e30b79689238afdfb4bb9585ff884e.tar.lz gsoc2013-epiphany-4bd35f5349e30b79689238afdfb4bb9585ff884e.tar.xz gsoc2013-epiphany-4bd35f5349e30b79689238afdfb4bb9585ff884e.tar.zst gsoc2013-epiphany-4bd35f5349e30b79689238afdfb4bb9585ff884e.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
Diffstat (limited to 'embed/ephy-web-view.c')
-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 4f6a7d24e..1aa37f74d 100644 --- a/embed/ephy-web-view.c +++ b/embed/ephy-web-view.c @@ -1815,6 +1815,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, @@ -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) { |