From de353621650d17a412b6ffe2cbf0366db5f11c40 Mon Sep 17 00:00:00 2001 From: Ben Murdoch Date: Mon, 12 Oct 2009 10:29:00 +0100 Subject: Don't allow the user to save bookmarks with a scheme that the Browser cannot directly handle. Change-Id: I9cbdfeaaeef4ded3dac1623854ecb9c5c603eb91 --- src/com/android/browser/Bookmarks.java | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/com/android/browser/Bookmarks.java') diff --git a/src/com/android/browser/Bookmarks.java b/src/com/android/browser/Bookmarks.java index c8aaee700..8d98f8995 100644 --- a/src/com/android/browser/Bookmarks.java +++ b/src/com/android/browser/Bookmarks.java @@ -41,6 +41,18 @@ import java.util.Date; private static String[] SELECTION_ARGS; + // We only want the user to be able to bookmark content that + // the browser can handle directly. + private static final String acceptableBookmarkSchemes[] = { + "http:", + "https:", + "about:", + "data:", + "javascript:", + "file:", + "content:" + }; + /** * Add a bookmark to the database. * @param context Context of the calling Activity. This is used to make @@ -214,4 +226,17 @@ import java.util.Date; bm.compress(Bitmap.CompressFormat.PNG, 100, os); return os.toByteArray(); } + + /* package */ static boolean urlHasAcceptableScheme(String url) { + if (url == null) { + return false; + } + + for (int i = 0; i < acceptableBookmarkSchemes.length; i++) { + if (url.startsWith(acceptableBookmarkSchemes[i])) { + return true; + } + } + return false; + } } -- cgit v1.2.3