[epiphany/gnome-40] Allow pdfjs only for GET requests



commit b2829e2b8a20f13d3348d5dd3af0d47e66cb1a0d
Author: Jan-Michael Brummer <jan brummer tabos org>
Date:   Tue Aug 10 15:51:39 2021 +0200

    Allow pdfjs only for GET requests
    
    Use internal pdf viewer only for GET. In case it is a POST request download it.
    
    Fixes: https://gitlab.gnome.org/GNOME/epiphany/-/issues/1505
    Part-of: <https://gitlab.gnome.org/GNOME/epiphany/-/merge_requests/1001>
    
    
    (cherry picked from commit 83d5af70f431f0540811e4adcb19e666290413e8)

 embed/ephy-web-view.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index bfd6e53d4..2b1f1ee9f 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -873,6 +873,8 @@ decide_policy_cb (WebKitWebView            *web_view,
 
   /* If it's not the main resource, we don't need to set the document type. */
   if (is_main_resource) {
+    const char *method = webkit_uri_request_get_http_method (request);
+
     type = EPHY_WEB_VIEW_DOCUMENT_OTHER;
     if (strcmp (mime_type, "text/html") == 0 || strcmp (mime_type, "text/plain") == 0) {
       type = EPHY_WEB_VIEW_DOCUMENT_HTML;
@@ -880,7 +882,7 @@ decide_policy_cb (WebKitWebView            *web_view,
       type = EPHY_WEB_VIEW_DOCUMENT_XML;
     } else if (strncmp (mime_type, "image/", 6) == 0) {
       type = EPHY_WEB_VIEW_DOCUMENT_IMAGE;
-    } else if (strcmp (mime_type, "application/pdf") == 0) {
+    } else if (strcmp (mime_type, "application/pdf") == 0 && strcmp (method, "GET") == 0) {
       g_autofree char *pdf_uri = NULL;
 
       /* FIXME: figure out how to make PDFs work in iframes. */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]