cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bows...@apache.org
Subject android commit: CB-2099: Android Whitelisting now blocks images and JS with an empty response
Date Wed, 06 Mar 2013 22:56:38 GMT
Updated Branches:
  refs/heads/master 7cc8fd7e8 -> 409b9af39


CB-2099: Android Whitelisting now blocks images and JS with an empty response


Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/409b9af3
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/409b9af3
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/409b9af3

Branch: refs/heads/master
Commit: 409b9af3980e136226e78511222885767d0b7253
Parents: 7cc8fd7
Author: Joe Bowser <bowserj@apache.org>
Authored: Wed Mar 6 14:56:27 2013 -0800
Committer: Joe Bowser <bowserj@apache.org>
Committed: Wed Mar 6 14:56:27 2013 -0800

----------------------------------------------------------------------
 .../org/apache/cordova/CordovaWebViewClient.java   |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/409b9af3/framework/src/org/apache/cordova/CordovaWebViewClient.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaWebViewClient.java b/framework/src/org/apache/cordova/CordovaWebViewClient.java
index 85f481d..b1aa0f0 100755
--- a/framework/src/org/apache/cordova/CordovaWebViewClient.java
+++ b/framework/src/org/apache/cordova/CordovaWebViewClient.java
@@ -18,6 +18,7 @@
 */
 package org.apache.cordova;
 
+import java.io.ByteArrayInputStream;
 import java.util.Hashtable;
 
 import org.apache.cordova.api.CordovaInterface;
@@ -220,11 +221,24 @@ public class CordovaWebViewClient extends WebViewClient {
      */
     @Override
     public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
+        //If something isn't whitelisted, just send a blank response
+        if(!Config.isUrlWhiteListed(url))
+        {
+            return getWhitelistResponse();
+        }
     	if (this.appView.pluginManager != null) {
             return this.appView.pluginManager.shouldInterceptRequest(url);
         }
         return null;
     }
+    
+    private WebResourceResponse getWhitelistResponse()
+    {
+        WebResourceResponse emptyResponse;
+        String empty = "";
+        ByteArrayInputStream data = new ByteArrayInputStream(empty.getBytes());
+        return new WebResourceResponse("text/plain", "UTF-8", data);
+    }
 
     /**
      * On received http auth request.


Mime
View raw message