From 2cdb0403a81821e144998c8d9a00d338d6ece3ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=A8=E3=83=AA=E3=82=B9?= Date: Wed, 28 Jul 2021 01:12:56 +0900 Subject: [PATCH] feat!: remove deprecated whitelist usage (#307) --- src/android/FileTransfer.java | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/src/android/FileTransfer.java b/src/android/FileTransfer.java index 5a3c5d6..00bd30f 100644 --- a/src/android/FileTransfer.java +++ b/src/android/FileTransfer.java @@ -45,7 +45,6 @@ import org.apache.cordova.CordovaResourceApi.OpenForReadResult; import org.apache.cordova.LOG; import org.apache.cordova.PluginManager; import org.apache.cordova.PluginResult; -import org.apache.cordova.Whitelist; import org.apache.cordova.file.FileUtils; import org.json.JSONArray; import org.json.JSONException; @@ -676,25 +675,11 @@ public class FileTransfer extends CordovaPlugin { return; } - /* This code exists for compatibility between 3.x and 4.x versions of Cordova. - * Previously the CordovaWebView class had a method, getWhitelist, which would - * return a Whitelist object. Since the fixed whitelist is removed in Cordova 4.x, - * the correct call now is to shouldAllowRequest from the plugin manager. - */ Boolean shouldAllowRequest = null; if (isLocalTransfer) { shouldAllowRequest = true; } - if (shouldAllowRequest == null) { - try { - Method gwl = webView.getClass().getMethod("getWhitelist"); - Whitelist whitelist = (Whitelist)gwl.invoke(webView); - shouldAllowRequest = whitelist.isUrlWhiteListed(source); - } catch (NoSuchMethodException e) { - } catch (IllegalAccessException e) { - } catch (InvocationTargetException e) { - } - } + if (shouldAllowRequest == null) { try { Method gpm = webView.getClass().getMethod("getPluginManager"); @@ -708,13 +693,12 @@ public class FileTransfer extends CordovaPlugin { } if (!Boolean.TRUE.equals(shouldAllowRequest)) { - LOG.w(LOG_TAG, "Source URL is not in white list: '" + source + "'"); + LOG.w(LOG_TAG, "The Source URL is not in the Allow List: '" + source + "'"); JSONObject error = createFileTransferError(CONNECTION_ERR, source, target, null, 401, null); callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.IO_EXCEPTION, error)); return; } - final RequestContext context = new RequestContext(source, target, callbackContext); synchronized (activeRequests) { activeRequests.put(objectId, context);