You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bo...@apache.org on 2013/03/07 17:52:15 UTC

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

Updated Branches:
  refs/heads/master 9924dc0f9 -> 5e8959bab


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


Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/5e8959ba
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/5e8959ba
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/5e8959ba

Branch: refs/heads/master
Commit: 5e8959bab1ce0ba324535b558f27e055ad7c751e
Parents: 9924dc0
Author: Joe Bowser <bo...@apache.org>
Authored: Thu Mar 7 08:52:02 2013 -0800
Committer: Joe Bowser <bo...@apache.org>
Committed: Thu Mar 7 08:52:02 2013 -0800

----------------------------------------------------------------------
 .../org/apache/cordova/CordovaChromeClient.java    |    2 +-
 .../src/org/apache/cordova/CordovaWebView.java     |   19 ++++-----------
 .../org/apache/cordova/CordovaWebViewClient.java   |    2 +-
 3 files changed, 7 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/5e8959ba/framework/src/org/apache/cordova/CordovaChromeClient.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaChromeClient.java b/framework/src/org/apache/cordova/CordovaChromeClient.java
index e650781..fb6d45f 100755
--- a/framework/src/org/apache/cordova/CordovaChromeClient.java
+++ b/framework/src/org/apache/cordova/CordovaChromeClient.java
@@ -205,7 +205,7 @@ public class CordovaChromeClient extends WebChromeClient {
         // Security check to make sure any requests are coming from the page initially
         // loaded in webview and not another loaded in an iframe.
         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;
         }
 

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/5e8959ba/framework/src/org/apache/cordova/CordovaWebView.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaWebView.java b/framework/src/org/apache/cordova/CordovaWebView.java
index e61a215..e653a95 100755
--- a/framework/src/org/apache/cordova/CordovaWebView.java
+++ b/framework/src/org/apache/cordova/CordovaWebView.java
@@ -76,7 +76,6 @@ public class CordovaWebView extends WebView {
     private CordovaChromeClient chromeClient;
 
     private String url;
-    String baseUrl;
 
     // Flag to track that a loadUrl timeout occurred
     int loadUrlTimeout = 0;
@@ -208,7 +207,8 @@ public class CordovaWebView extends WebView {
 
 
     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));
         }
@@ -405,17 +405,8 @@ public class CordovaWebView extends WebView {
         LOG.d(TAG, ">>> loadUrl(" + url + ")");
 
         this.url = url;
-        if (this.baseUrl == null) {
-            int i = url.lastIndexOf('/');
-            if (i > 0) {
-                this.baseUrl = url.substring(0, i + 1);
-            }
-            else {
-                this.baseUrl = this.url + "/";
-            }
+        this.pluginManager.init();
 
-            this.pluginManager.init();
-        }
 
         // Create a timeout timer for loadUrl
         final CordovaWebView me = this;
@@ -470,7 +461,7 @@ public class CordovaWebView extends WebView {
         if (LOG.isLoggable(LOG.DEBUG) && !url.startsWith("javascript:")) {
             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);
         }
     }
@@ -576,7 +567,7 @@ public class CordovaWebView extends WebView {
         if (!openExternal) {
 
             // 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?
                 // Load new URL
                 this.loadUrl(url);

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/5e8959ba/framework/src/org/apache/cordova/CordovaWebViewClient.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaWebViewClient.java b/framework/src/org/apache/cordova/CordovaWebViewClient.java
index b937d98..4751fc3 100755
--- a/framework/src/org/apache/cordova/CordovaWebViewClient.java
+++ b/framework/src/org/apache/cordova/CordovaWebViewClient.java
@@ -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.
             // 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;
             }