diff options
author | Selim Gurun <sgurun@google.com> | 2014-01-16 07:30:51 -0800 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-01-16 07:30:51 -0800 |
commit | 5f9ac43a65943dc1769d08c7464395af9b7ff7da (patch) | |
tree | 256b2a4efd22a4df09834384fdf9cf9358b182ba /src | |
parent | 65807544377db0f643fa67b7bcd26373b8801c42 (diff) | |
parent | 66d2de91e8a6741ea86c1da3faf1cfa28b515287 (diff) | |
download | packages_apps_Browser-5f9ac43a65943dc1769d08c7464395af9b7ff7da.zip packages_apps_Browser-5f9ac43a65943dc1769d08c7464395af9b7ff7da.tar.gz packages_apps_Browser-5f9ac43a65943dc1769d08c7464395af9b7ff7da.tar.bz2 |
am 66d2de91: am 1e395bf5: am e3e09d43: am dea3d2ad: am 81cb07dc: am f8c18437: am 699496ca: am 6243e7cb: Restrict loading private browser files
* commit '66d2de91e8a6741ea86c1da3faf1cfa28b515287':
Restrict loading private browser files
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/browser/Tab.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java index 026799b..7d2fe1e 100644 --- a/src/com/android/browser/Tab.java +++ b/src/com/android/browser/Tab.java @@ -69,6 +69,7 @@ import com.android.browser.TabControl.OnThumbnailUpdatedListener; import com.android.browser.homepages.HomeProvider; import com.android.browser.provider.SnapshotProvider.Snapshots; +import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; @@ -98,6 +99,8 @@ class Tab implements PictureListener { private static final int CAPTURE_DELAY = 100; private static final int INITIAL_PROGRESS = 5; + private static final String RESTRICTED = "<html><body>not allowed</body></html>"; + private static Bitmap sDefaultFavicon; private static Paint sAlphaPaint = new Paint(); @@ -574,6 +577,24 @@ class Tab implements PictureListener { @Override public WebResourceResponse shouldInterceptRequest(WebView view, String url) { + Uri uri = Uri.parse(url); + if (uri.getScheme().toLowerCase().equals("file")) { + File file = new File(uri.getPath()); + try { + if (file.getCanonicalPath().startsWith( + mContext.getDatabasePath("foo").getParent())) { + return new WebResourceResponse("text/html","UTF-8", + new ByteArrayInputStream(RESTRICTED.getBytes("UTF-8"))); + } + } catch (Exception ex) { + Log.e(LOGTAG, "Bad canonical path" + ex.toString()); + try { + return new WebResourceResponse("text/html","UTF-8", + new ByteArrayInputStream(RESTRICTED.getBytes("UTF-8"))); + } catch (java.io.UnsupportedEncodingException e) { + } + } + } WebResourceResponse res = HomeProvider.shouldInterceptRequest( mContext, url); return res; |