mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-21 08:05:19 +08:00
CB-2099: Android Whitelisting now blocks images and JS with an empty response
This commit is contained in:
parent
7cc8fd7e87
commit
409b9af398
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user