[Xfce4-commits] <postler:master> Block external images, unless explicitly allowed

Christian Dywan noreply at xfce.org
Sat Jul 10 00:24:01 CEST 2010


Updating branch refs/heads/master
         to 8ebb0bcc6944df371d81dfc0dd565fcc60d3706c (commit)
       from 74a816ca39e59ce063cc040bd2d2bd674ce3bcf7 (commit)

commit 8ebb0bcc6944df371d81dfc0dd565fcc60d3706c
Author: Christian Dywan <christian at twotoasts.de>
Date:   Sat Jun 26 21:30:49 2010 +0200

    Block external images, unless explicitly allowed

 postler/postler-content.vala |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/postler/postler-content.vala b/postler/postler-content.vala
index d036da1..00898a6 100644
--- a/postler/postler-content.vala
+++ b/postler/postler-content.vala
@@ -26,6 +26,7 @@ public class Postler.Content : WebKit.WebView {
     string x_mailer;
 
     public string default_charset { get; set; default = "ISO-8859-1"; }
+    public bool allow_external_images { get; set; default = false; }
 
     public string? last_location { get; set; }
     public string? sender { get; set; }
@@ -85,6 +86,7 @@ public class Postler.Content : WebKit.WebView {
         if (settings.get_class ().find_property ("enable-private-browsing") != null) {
             settings.set ("enable-private-browsing", true);
         }
+        resource_request_starting.connect (resource_request);
         navigation_policy_decision_requested.connect (navigation_decision);
         create_web_view.connect (new_window_created);
         populate_popup.connect (populate_menu);
@@ -635,7 +637,11 @@ public class Postler.Content : WebKit.WebView {
         }
     }
 
-    /* TODO: resource request, block external images */
+    void resource_request (WebKit.WebFrame frame, WebKit.WebResource resouce,
+        WebKit.NetworkRequest request, WebKit.NetworkResponse? response) {
+        if (!allow_external_images && request.uri.has_prefix ("http"))
+            request.uri = "about:blank";
+    }
 
     bool navigation_decision (WebKit.WebFrame web_frame,
         WebKit.NetworkRequest request, WebKit.WebNavigationAction action,



More information about the Xfce4-commits mailing list