Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2044)

Unified Diff: android_webview/java/src/org/chromium/android_webview/AwContentViewClient.java

Issue 2524843003: WebView: Add scheme whitelist for content intents. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/public/android/java/src/org/chromium/content/browser/ContentViewClient.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/java/src/org/chromium/android_webview/AwContentViewClient.java
diff --git a/android_webview/java/src/org/chromium/android_webview/AwContentViewClient.java b/android_webview/java/src/org/chromium/android_webview/AwContentViewClient.java
index f109688a8977e63aa18d25d6893a344eaf113729..98622d8327c13f081e08099b1ff1a46c36870f86 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContentViewClient.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContentViewClient.java
@@ -5,14 +5,20 @@
package org.chromium.android_webview;
import android.content.Context;
+import android.content.Intent;
import android.view.KeyEvent;
+import org.chromium.base.Log;
import org.chromium.content.browser.ContentViewClient;
+import java.net.URISyntaxException;
+
/**
* ContentViewClient implementation for WebView
*/
public class AwContentViewClient extends ContentViewClient {
+ private static final String TAG = "AwCVC";
+
private final AwContentsClient mAwContentsClient;
private final AwSettings mAwSettings;
private final AwContents mAwContents;
@@ -33,6 +39,20 @@ public class AwContentViewClient extends ContentViewClient {
@Override
public void onStartContentIntent(Context context, String contentUrl, boolean isMainFrame) {
+ // Make sure that this URL is a valid scheme for this callback if interpreted as an intent,
+ // even though we don't dispatch it as an intent here, because many WebView apps will once
+ // it reaches them.
+ String scheme = null;
+ try {
+ Intent intent = Intent.parseUri(contentUrl, Intent.URI_INTENT_SCHEME);
+ scheme = intent.getScheme();
+ } catch (URISyntaxException e) {
+ // Just don't set the scheme, it will be rejected.
+ }
+ if (!isAcceptableContentIntentScheme(scheme)) {
+ Log.w(TAG, "Invalid scheme for URI %s", contentUrl);
+ return;
+ }
// Comes from WebViewImpl::detectContentOnTouch in Blink, so must be user-initiated, and
// isn't a redirect.
mAwContentsClient.shouldIgnoreNavigation(context, contentUrl, isMainFrame, true, false);
« no previous file with comments | « no previous file | content/public/android/java/src/org/chromium/content/browser/ContentViewClient.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698