summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSelim Gurun <sgurun@google.com>2014-01-14 17:27:54 -0800
committerSelim Gurun <sgurun@google.com>2014-01-15 16:11:03 -0800
commit6243e7cb0eb836af28b23a2e00d89627b90496e4 (patch)
tree7f71d892647cb7cb8b1289a5cd3b80bf90f8faee /src
parent7719d6ca3fd4079add8a9648838d99244a237eaf (diff)
downloadBrowser-6243e7cb0eb836af28b23a2e00d89627b90496e4.tar.gz
Restrict loading private browser files
Bug:11516871 Change-Id: I6a717a157f3d29edfffc36dc2da45c6df30d6ccd
Diffstat (limited to 'src')
-rw-r--r--src/com/android/browser/Tab.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java
index 28734bd6..2f00b268 100644
--- a/src/com/android/browser/Tab.java
+++ b/src/com/android/browser/Tab.java
@@ -71,6 +71,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;
@@ -100,6 +101,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();
@@ -623,6 +626,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;