Skip to content

Commit 2cdb040

Browse files
authoredJul 27, 2021
feat!: remove deprecated whitelist usage (#307)
1 parent 648b577 commit 2cdb040

File tree

1 file changed

+2
-18
lines changed

1 file changed

+2
-18
lines changed
 

‎src/android/FileTransfer.java

+2-18
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ Licensed to the Apache Software Foundation (ASF) under one
4545
import org.apache.cordova.LOG;
4646
import org.apache.cordova.PluginManager;
4747
import org.apache.cordova.PluginResult;
48-
import org.apache.cordova.Whitelist;
4948
import org.apache.cordova.file.FileUtils;
5049
import org.json.JSONArray;
5150
import org.json.JSONException;
@@ -676,25 +675,11 @@ private void download(final String source, final String target, JSONArray args,
676675
return;
677676
}
678677

679-
/* This code exists for compatibility between 3.x and 4.x versions of Cordova.
680-
* Previously the CordovaWebView class had a method, getWhitelist, which would
681-
* return a Whitelist object. Since the fixed whitelist is removed in Cordova 4.x,
682-
* the correct call now is to shouldAllowRequest from the plugin manager.
683-
*/
684678
Boolean shouldAllowRequest = null;
685679
if (isLocalTransfer) {
686680
shouldAllowRequest = true;
687681
}
688-
if (shouldAllowRequest == null) {
689-
try {
690-
Method gwl = webView.getClass().getMethod("getWhitelist");
691-
Whitelist whitelist = (Whitelist)gwl.invoke(webView);
692-
shouldAllowRequest = whitelist.isUrlWhiteListed(source);
693-
} catch (NoSuchMethodException e) {
694-
} catch (IllegalAccessException e) {
695-
} catch (InvocationTargetException e) {
696-
}
697-
}
682+
698683
if (shouldAllowRequest == null) {
699684
try {
700685
Method gpm = webView.getClass().getMethod("getPluginManager");
@@ -708,13 +693,12 @@ private void download(final String source, final String target, JSONArray args,
708693
}
709694

710695
if (!Boolean.TRUE.equals(shouldAllowRequest)) {
711-
LOG.w(LOG_TAG, "Source URL is not in white list: '" + source + "'");
696+
LOG.w(LOG_TAG, "The Source URL is not in the Allow List: '" + source + "'");
712697
JSONObject error = createFileTransferError(CONNECTION_ERR, source, target, null, 401, null);
713698
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.IO_EXCEPTION, error));
714699
return;
715700
}
716701

717-
718702
final RequestContext context = new RequestContext(source, target, callbackContext);
719703
synchronized (activeRequests) {
720704
activeRequests.put(objectId, context);

0 commit comments

Comments
 (0)
Failed to load comments.