Fixing CB-343: We need to respect the whitelist

This commit is contained in:
Joe Bowser 2012-03-16 10:55:06 -07:00
parent dc93556ef0
commit 04b3e4d847
3 changed files with 30 additions and 21 deletions

View File

@ -1333,7 +1333,7 @@ public class DroidGap extends Activity implements CordovaInterface {
* @param url
* @return
*/
boolean isUrlWhiteListed(String url) {
public boolean isUrlWhiteListed(String url) {
// Check to see if we have matched url previously
if (whiteListCache.get(url) != null) {

View File

@ -416,6 +416,8 @@ public class FileTransfer extends Plugin {
file.getParentFile().mkdirs();
// connect to server
if(this.ctx.isUrlWhiteListed(source))
{
URL url = new URL(source);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
@ -442,6 +444,11 @@ public class FileTransfer extends Plugin {
FileUtils fileUtil = new FileUtils();
return fileUtil.getEntry(file);
}
else
{
throw new IOException("Error: Unable to connect to domain");
}
} catch (Exception e) {
Log.d(LOG_TAG, e.getMessage(), e);
throw new IOException("Error while downloading");

View File

@ -142,4 +142,6 @@ public interface CordovaInterface {
public abstract Context getApplicationContext();
public abstract boolean isUrlWhiteListed(String source);
}