[epiphany/mcatanzaro/pdf-hijack!] Fix PDF subresources hijacking the main resource
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/mcatanzaro/pdf-hijack!] Fix PDF subresources hijacking the main resource
- Date: Wed, 22 Jan 2020 19:53:03 +0000 (UTC)
commit b32b6946641951169880411bb8275260a1e9c8a7
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Wed Jan 22 13:51:03 2020 -0600
Fix PDF subresources hijacking the main resource
If a PDF is used in a subresource, e.g. an iframe, currently we will
start a main resource load to view that PDF, which is never right. Only
enter PDF mode if the PDF is the main resource.
Now, PDF subresources are still going to be broken, e.g. when a website
attempts to display a PDF in an iframe. That's still not going to work.
But that never worked before, and at least we won't try to load it as
the main resource.
embed/ephy-web-view.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index 49f59f9b7..03d3958c4 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -870,6 +870,7 @@ ephy_web_view_decide_policy (WebKitWebView *web_view,
EphyWebViewDocumentType type;
const char *mime_type;
const char *request_uri;
+ gboolean is_main_resource;
if (decision_type != WEBKIT_POLICY_DECISION_TYPE_RESPONSE)
return FALSE;
@@ -880,10 +881,12 @@ ephy_web_view_decide_policy (WebKitWebView *web_view,
request = webkit_response_policy_decision_get_request (response_decision);
request_uri = webkit_uri_request_get_uri (request);
- if (strcmp (mime_type, "application/pdf") == 0) {
- EphyWebView *view = EPHY_WEB_VIEW (web_view);
+ main_resource = webkit_web_view_get_main_resource (web_view);
+ is_main_resource = g_strcmp0 (webkit_web_resource_get_uri (main_resource), request_uri) == 0;
- view->in_pdf_viewer = TRUE;
+ if (is_main_resource && strcmp (mime_type, "application/pdf") == 0) {
+ /* TODO: figure out how to make PDFs work in iframes */
+ EPHY_WEB_VIEW (web_view)->in_pdf_viewer = TRUE;
}
/* If WebKit can't handle the mime type start the download
@@ -892,8 +895,7 @@ ephy_web_view_decide_policy (WebKitWebView *web_view,
return FALSE;
/* If it's not the main resource we don't need to set the document type. */
- main_resource = webkit_web_view_get_main_resource (web_view);
- if (g_strcmp0 (webkit_web_resource_get_uri (main_resource), request_uri) != 0)
+ if (!is_main_resource)
return FALSE;
type = EPHY_WEB_VIEW_DOCUMENT_OTHER;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]