summaryrefslogtreecommitdiffstats
path: root/src/com/android/browser/Tab.java
diff options
context:
space:
mode:
authorPaul Miller <paulmiller@google.com>2015-04-06 17:15:15 +0000
committerPaul Miller <paulmiller@google.com>2015-04-06 17:15:15 +0000
commit3fa0e8adb2faf92b1529d0ac39ea16b5adc3d3b4 (patch)
treedca2398555080eeb6af2ef6be79ce40c7c72431e /src/com/android/browser/Tab.java
parentca7ecd85ac925ef44dbef327310f2baad13322f2 (diff)
downloadpackages_apps_Browser-3fa0e8adb2faf92b1529d0ac39ea16b5adc3d3b4.zip
packages_apps_Browser-3fa0e8adb2faf92b1529d0ac39ea16b5adc3d3b4.tar.gz
packages_apps_Browser-3fa0e8adb2faf92b1529d0ac39ea16b5adc3d3b4.tar.bz2
Revert "Restrict "javascript" and "file" scheme intents"
This reverts commit ca7ecd85ac925ef44dbef327310f2baad13322f2. Change-Id: I64460956e6243908a6c575eb4d3c7455efc86dff
Diffstat (limited to 'src/com/android/browser/Tab.java')
-rw-r--r--src/com/android/browser/Tab.java26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java
index a4d2ce0..dc1944e 100644
--- a/src/com/android/browser/Tab.java
+++ b/src/com/android/browser/Tab.java
@@ -74,7 +74,9 @@ 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;
import java.io.OutputStream;
import java.nio.ByteBuffer;
@@ -103,6 +105,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();
@@ -605,7 +609,27 @@ class Tab implements PictureListener {
@Override
public WebResourceResponse shouldInterceptRequest(WebView view,
String url) {
- return HomeProvider.shouldInterceptRequest(mContext, url);
+ Uri uri = Uri.parse(url);
+ if (uri.getScheme().toLowerCase().equals("file")) {
+ File file = new File(uri.getPath());
+ try {
+ if (file.getCanonicalPath().startsWith(
+ mContext.getApplicationContext().getApplicationInfo().dataDir)) {
+ 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;
}
@Override