mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-26 20:33:07 +08:00
Fixing CB-343: We need to respect the whitelist
This commit is contained in:
parent
dc93556ef0
commit
04b3e4d847
@ -1333,7 +1333,7 @@ public class DroidGap extends Activity implements CordovaInterface {
|
|||||||
* @param url
|
* @param url
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
boolean isUrlWhiteListed(String url) {
|
public boolean isUrlWhiteListed(String url) {
|
||||||
|
|
||||||
// Check to see if we have matched url previously
|
// Check to see if we have matched url previously
|
||||||
if (whiteListCache.get(url) != null) {
|
if (whiteListCache.get(url) != null) {
|
||||||
|
@ -416,6 +416,8 @@ public class FileTransfer extends Plugin {
|
|||||||
file.getParentFile().mkdirs();
|
file.getParentFile().mkdirs();
|
||||||
|
|
||||||
// connect to server
|
// connect to server
|
||||||
|
if(this.ctx.isUrlWhiteListed(source))
|
||||||
|
{
|
||||||
URL url = new URL(source);
|
URL url = new URL(source);
|
||||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||||
connection.setRequestMethod("GET");
|
connection.setRequestMethod("GET");
|
||||||
@ -442,6 +444,11 @@ public class FileTransfer extends Plugin {
|
|||||||
FileUtils fileUtil = new FileUtils();
|
FileUtils fileUtil = new FileUtils();
|
||||||
|
|
||||||
return fileUtil.getEntry(file);
|
return fileUtil.getEntry(file);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new IOException("Error: Unable to connect to domain");
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.d(LOG_TAG, e.getMessage(), e);
|
Log.d(LOG_TAG, e.getMessage(), e);
|
||||||
throw new IOException("Error while downloading");
|
throw new IOException("Error while downloading");
|
||||||
|
@ -142,4 +142,6 @@ public interface CordovaInterface {
|
|||||||
|
|
||||||
public abstract Context getApplicationContext();
|
public abstract Context getApplicationContext();
|
||||||
|
|
||||||
|
public abstract boolean isUrlWhiteListed(String source);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user