Removing baseURL because it doesn't actually do anything. If we want to make sure remote websites work, we whitelist them

This commit is contained in:
Joe Bowser 2013-03-07 08:52:02 -08:00
parent 9924dc0f92
commit 5e8959bab1
3 changed files with 7 additions and 16 deletions

View File

@ -205,7 +205,7 @@ public class CordovaChromeClient extends WebChromeClient {
// Security check to make sure any requests are coming from the page initially // Security check to make sure any requests are coming from the page initially
// loaded in webview and not another loaded in an iframe. // loaded in webview and not another loaded in an iframe.
boolean reqOk = false; boolean reqOk = false;
if (url.startsWith("file://") || url.indexOf(this.appView.baseUrl) == 0 || Config.isUrlWhiteListed(url)) { if (url.startsWith("file://") || Config.isUrlWhiteListed(url)) {
reqOk = true; reqOk = true;
} }

View File

@ -76,7 +76,6 @@ public class CordovaWebView extends WebView {
private CordovaChromeClient chromeClient; private CordovaChromeClient chromeClient;
private String url; private String url;
String baseUrl;
// Flag to track that a loadUrl timeout occurred // Flag to track that a loadUrl timeout occurred
int loadUrlTimeout = 0; int loadUrlTimeout = 0;
@ -208,7 +207,8 @@ public class CordovaWebView extends WebView {
private void initWebViewClient(CordovaInterface cordova) { private void initWebViewClient(CordovaInterface cordova) {
if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB ||
android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.JELLY_BEAN_MR1)
{ {
this.setWebViewClient(new CordovaWebViewClient(this.cordova, this)); this.setWebViewClient(new CordovaWebViewClient(this.cordova, this));
} }
@ -405,17 +405,8 @@ public class CordovaWebView extends WebView {
LOG.d(TAG, ">>> loadUrl(" + url + ")"); LOG.d(TAG, ">>> loadUrl(" + url + ")");
this.url = url; this.url = url;
if (this.baseUrl == null) { this.pluginManager.init();
int i = url.lastIndexOf('/');
if (i > 0) {
this.baseUrl = url.substring(0, i + 1);
}
else {
this.baseUrl = this.url + "/";
}
this.pluginManager.init();
}
// Create a timeout timer for loadUrl // Create a timeout timer for loadUrl
final CordovaWebView me = this; final CordovaWebView me = this;
@ -470,7 +461,7 @@ public class CordovaWebView extends WebView {
if (LOG.isLoggable(LOG.DEBUG) && !url.startsWith("javascript:")) { if (LOG.isLoggable(LOG.DEBUG) && !url.startsWith("javascript:")) {
LOG.d(TAG, ">>> loadUrlNow()"); LOG.d(TAG, ">>> loadUrlNow()");
} }
if (url.startsWith("file://") || url.indexOf(this.baseUrl) == 0 || url.startsWith("javascript:") || Config.isUrlWhiteListed(url)) { if (url.startsWith("file://") || url.startsWith("javascript:") || Config.isUrlWhiteListed(url)) {
super.loadUrl(url); super.loadUrl(url);
} }
} }
@ -576,7 +567,7 @@ public class CordovaWebView extends WebView {
if (!openExternal) { if (!openExternal) {
// Make sure url is in whitelist // Make sure url is in whitelist
if (url.startsWith("file://") || url.indexOf(this.baseUrl) == 0 || Config.isUrlWhiteListed(url)) { if (url.startsWith("file://") || Config.isUrlWhiteListed(url)) {
// TODO: What about params? // TODO: What about params?
// Load new URL // Load new URL
this.loadUrl(url); this.loadUrl(url);

View File

@ -194,7 +194,7 @@ public class CordovaWebViewClient extends WebViewClient {
// If our app or file:, then load into a new Cordova webview container by starting a new instance of our activity. // If our app or file:, then load into a new Cordova webview container by starting a new instance of our activity.
// Our app continues to run. When BACK is pressed, our app is redisplayed. // Our app continues to run. When BACK is pressed, our app is redisplayed.
if (url.startsWith("file://") || url.startsWith("data:") || url.indexOf(this.appView.baseUrl) == 0 || Config.isUrlWhiteListed(url)) { if (url.startsWith("file://") || url.startsWith("data:") || Config.isUrlWhiteListed(url)) {
return false; return false;
} }