mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-22 08:53:24 +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;
|
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.
|
||||||
|
Loading…
Reference in New Issue
Block a user