diff options
author | Magnus Lindhult <magnus.lindhult@sonyericsson.com> | 2010-09-29 18:36:07 +0200 |
---|---|---|
committer | Johan Redestig <johan.redestig@sonyericsson.com> | 2010-09-30 09:35:27 +0200 |
commit | 655e867add447f1e1aeb84557b02ea18d8ea1b34 (patch) | |
tree | 771403c0fc916b640db95dd803ce6160c34bdabc /src/com/android/browser/BrowserProvider.java | |
parent | cba8d0efd388146f6814c83a363f4facdec5be2f (diff) | |
download | packages_apps_Browser-655e867add447f1e1aeb84557b02ea18d8ea1b34.zip packages_apps_Browser-655e867add447f1e1aeb84557b02ea18d8ea1b34.tar.gz packages_apps_Browser-655e867add447f1e1aeb84557b02ea18d8ea1b34.tar.bz2 |
Protection against bookmarks with url=null in the database
Modified the database to only accept bookmarks with a url != null,
as a bookmark without url has no meaning and also makes the Browser
crash in a number of places.
Change-Id: I0a90c32a5c8846b96a231fb95b203aef4761f52d
Diffstat (limited to 'src/com/android/browser/BrowserProvider.java')
-rw-r--r-- | src/com/android/browser/BrowserProvider.java | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/com/android/browser/BrowserProvider.java b/src/com/android/browser/BrowserProvider.java index bf1f9d5..a6ceb8b 100644 --- a/src/com/android/browser/BrowserProvider.java +++ b/src/com/android/browser/BrowserProvider.java @@ -159,7 +159,8 @@ public class BrowserProvider extends ContentProvider { // 20 -> 21 Added touch_icon // 21 -> 22 Remove "clientid" // 22 -> 23 Added user_entered - private static final int DATABASE_VERSION = 23; + // 23 -> 24 Url not allowed to be null anymore. + private static final int DATABASE_VERSION = 24; // Regular expression which matches http://, followed by some stuff, followed by // optionally a trailing slash, all matched as separate groups. @@ -239,7 +240,7 @@ public class BrowserProvider extends ContentProvider { db.execSQL("CREATE TABLE bookmarks (" + "_id INTEGER PRIMARY KEY," + "title TEXT," + - "url TEXT," + + "url TEXT NOT NULL," + "visits INTEGER," + "date LONG," + "created LONG," + @@ -291,6 +292,27 @@ public class BrowserProvider extends ContentProvider { } if (oldVersion < 23) { db.execSQL("ALTER TABLE bookmarks ADD COLUMN user_entered INTEGER;"); + } + if (oldVersion < 24) { + /* SQLite does not support ALTER COLUMN, hence the lengthy code. */ + db.execSQL("DELETE FROM bookmarks WHERE url IS NULL;"); + db.execSQL("ALTER TABLE bookmarks RENAME TO bookmarks_temp;"); + db.execSQL("CREATE TABLE bookmarks (" + + "_id INTEGER PRIMARY KEY," + + "title TEXT," + + "url TEXT NOT NULL," + + "visits INTEGER," + + "date LONG," + + "created LONG," + + "description TEXT," + + "bookmark INTEGER," + + "favicon BLOB DEFAULT NULL," + + "thumbnail BLOB DEFAULT NULL," + + "touch_icon BLOB DEFAULT NULL," + + "user_entered INTEGER" + + ");"); + db.execSQL("INSERT INTO bookmarks SELECT * FROM bookmarks_temp;"); + db.execSQL("DROP TABLE bookmarks_temp;"); } else { db.execSQL("DROP TABLE IF EXISTS bookmarks"); db.execSQL("DROP TABLE IF EXISTS searches"); |