DO NOT MERGE Merge commit '8225df00' into bp
Add a delimiter between scheme and host
Bug: 6923539
Change-Id: Ic5e19f96c64367c9dc0e3168850309cdd5047e47
diff --git a/core/java/android/webkit/BrowserFrame.java b/core/java/android/webkit/BrowserFrame.java
index 4dbca23..35aabf7 100644
--- a/core/java/android/webkit/BrowserFrame.java
+++ b/core/java/android/webkit/BrowserFrame.java
@@ -70,6 +70,7 @@
* request's LoadListener
*/
private final static int MAX_OUTSTANDING_REQUESTS = 300;
+ private final static String SCHEME_HOST_DELIMITER = "://";
private final CallbackProxy mCallbackProxy;
private final WebSettingsClassic mSettings;
@@ -500,9 +501,14 @@
.getCurrentItem();
if (item != null) {
WebAddress uri = new WebAddress(item.getUrl());
- String schemePlusHost = uri.getScheme() + uri.getHost();
+ String schemePlusHost = uri.getScheme() + SCHEME_HOST_DELIMITER +
+ uri.getHost();
String[] up = mDatabase.getUsernamePassword(
schemePlusHost);
+ if (up == null) { // no row found, try again using the legacy method
+ schemePlusHost = uri.getScheme() + uri.getHost();
+ up = mDatabase.getUsernamePassword(schemePlusHost);
+ }
if (up != null && up[0] != null) {
setUsernamePassword(up[0], up[1]);
}
@@ -817,7 +823,7 @@
}
WebAddress uri = new WebAddress(mCallbackProxy
.getBackForwardList().getCurrentItem().getUrl());
- String schemePlusHost = uri.getScheme() + uri.getHost();
+ String schemePlusHost = uri.getScheme() + SCHEME_HOST_DELIMITER + uri.getHost();
// Check to see if the username & password appear in
// the post data (there could be another form on the
// page and that was posted instead.
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index 6df7820..9feb513 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -595,7 +595,8 @@
* forms. Note that this is unrelated to the credentials used for HTTP
* authentication.
*
- * @param host the host that required the credentials
+ * @param host the host that required the credentials. It is recommended that
+ * the host is given using scheme://hostname format.
* @param username the username for the given host
* @param password the password for the given host
* @see WebViewDatabase#clearUsernamePassword
diff --git a/core/java/android/webkit/WebViewDatabaseClassic.java b/core/java/android/webkit/WebViewDatabaseClassic.java
index be01028..5ad4fa5 100644
--- a/core/java/android/webkit/WebViewDatabaseClassic.java
+++ b/core/java/android/webkit/WebViewDatabaseClassic.java
@@ -37,7 +37,7 @@
private static final String DATABASE_FILE = "webview.db";
private static final String CACHE_DATABASE_FILE = "webviewCache.db";
- private static final int DATABASE_VERSION = 11;
+ private static final int DATABASE_VERSION = 12;
// 2 -> 3 Modified Cache table to allow cache of redirects
// 3 -> 4 Added Oma-Downloads table
// 4 -> 5 Modified Cache table to support persistent contentLength
@@ -50,6 +50,7 @@
// 10 -> 11 Drop cookies and cache now managed by the chromium stack,
// and update the form data table to use the new format
// implemented for b/5265606.
+ // 11 -> 12 Add a delimiter between scheme and host when storing passwords
private static WebViewDatabaseClassic sInstance = null;
private static final Object sInstanceLock = new Object();
@@ -169,11 +170,23 @@
private static void upgradeDatabase() {
upgradeDatabaseToV10();
upgradeDatabaseFromV10ToV11();
+ upgradeDatabaseFromV11ToV12();
// Add future database upgrade functions here, one version at a
// time.
sDatabase.setVersion(DATABASE_VERSION);
}
+ private static void upgradeDatabaseFromV11ToV12() {
+ int oldVersion = sDatabase.getVersion();
+
+ if (oldVersion >= 12) {
+ // Nothing to do.
+ return;
+ }
+ // delete the rows in the database.
+ sDatabase.delete(mTableNames[TABLE_PASSWORD_ID], null, null);
+ }
+
private static void upgradeDatabaseFromV10ToV11() {
int oldVersion = sDatabase.getVersion();