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

This commit is contained in:
Joe Bowser 2013-03-06 14:56:27 -08:00
parent 7cc8fd7e87
commit 409b9af398

View File

@ -18,6 +18,7 @@
*/ */
package org.apache.cordova; package org.apache.cordova;
import java.io.ByteArrayInputStream;
import java.util.Hashtable; import java.util.Hashtable;
import org.apache.cordova.api.CordovaInterface; import org.apache.cordova.api.CordovaInterface;
@ -220,11 +221,24 @@ public class CordovaWebViewClient extends WebViewClient {
*/ */
@Override @Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) { 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) { if (this.appView.pluginManager != null) {
return this.appView.pluginManager.shouldInterceptRequest(url); return this.appView.pluginManager.shouldInterceptRequest(url);
} }
return null; 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. * On received http auth request.