Commit bf271f14 authored by jaekyun's avatar jaekyun Committed by Commit bot

Catch Exception for Intent.parseUri instead of URISyntaxException

Intent.parseUri can throw other excpetions like NumberFormatException.
So we need to catch Exception to avoid crash.

BUG=484336

Review URL: https://codereview.chromium.org/1134163002

Cr-Commit-Position: refs/heads/master@{#329482}
parent a2da0cfd
...@@ -9,21 +9,19 @@ import android.content.ActivityNotFoundException; ...@@ -9,21 +9,19 @@ import android.content.ActivityNotFoundException;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.provider.Browser; import android.provider.Browser;
import android.util.Log;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.View; import android.view.View;
import android.webkit.URLUtil; import android.webkit.URLUtil;
import android.webkit.WebChromeClient; import android.webkit.WebChromeClient;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import org.chromium.base.Log;
import org.chromium.content.browser.ContentVideoViewClient; import org.chromium.content.browser.ContentVideoViewClient;
import org.chromium.content.browser.ContentViewClient; import org.chromium.content.browser.ContentViewClient;
import org.chromium.content.browser.ContentViewCore; import org.chromium.content.browser.ContentViewCore;
import org.chromium.content.browser.SelectActionMode; import org.chromium.content.browser.SelectActionMode;
import org.chromium.content.browser.SelectActionModeCallback.ActionHandler; import org.chromium.content.browser.SelectActionModeCallback.ActionHandler;
import java.net.URISyntaxException;
/** /**
* ContentViewClient implementation for WebView * ContentViewClient implementation for WebView
*/ */
...@@ -62,8 +60,8 @@ public class AwContentViewClient extends ContentViewClient implements ContentVid ...@@ -62,8 +60,8 @@ public class AwContentViewClient extends ContentViewClient implements ContentVid
// Perform generic parsing of the URI to turn it into an Intent. // Perform generic parsing of the URI to turn it into an Intent.
try { try {
intent = Intent.parseUri(contentUrl, Intent.URI_INTENT_SCHEME); intent = Intent.parseUri(contentUrl, Intent.URI_INTENT_SCHEME);
} catch (URISyntaxException ex) { } catch (Exception ex) {
Log.w(TAG, "Bad URI " + contentUrl + ": " + ex.getMessage()); Log.w(TAG, "Bad URI " + contentUrl, ex);
return; return;
} }
// Sanitize the Intent, ensuring web pages can not bypass browser // Sanitize the Intent, ensuring web pages can not bypass browser
......
...@@ -23,16 +23,17 @@ import android.widget.ScrollView; ...@@ -23,16 +23,17 @@ import android.widget.ScrollView;
import android.widget.TextView; import android.widget.TextView;
import org.chromium.base.CalledByNative; import org.chromium.base.CalledByNative;
import org.chromium.base.Log;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.content_public.browser.WebContents; import org.chromium.content_public.browser.WebContents;
import org.chromium.content_public.browser.WebContentsObserver; import org.chromium.content_public.browser.WebContentsObserver;
import java.net.URISyntaxException;
/** /**
* Java side of Android implementation of the website settings UI. * Java side of Android implementation of the website settings UI.
*/ */
public class ConnectionInfoPopup implements OnClickListener { public class ConnectionInfoPopup implements OnClickListener {
private static final String TAG = "ConnectionInfoPopup";
private static final String HELP_URL = private static final String HELP_URL =
"http://www.google.com/support/chrome/bin/answer.py?answer=95617"; "http://www.google.com/support/chrome/bin/answer.py?answer=95617";
private static final int DESCRIPTION_TEXT_SIZE_SP = 12; private static final int DESCRIPTION_TEXT_SIZE_SP = 12;
...@@ -212,8 +213,9 @@ public class ConnectionInfoPopup implements OnClickListener { ...@@ -212,8 +213,9 @@ public class ConnectionInfoPopup implements OnClickListener {
i.putExtra(Browser.EXTRA_CREATE_NEW_TAB, true); i.putExtra(Browser.EXTRA_CREATE_NEW_TAB, true);
i.putExtra(Browser.EXTRA_APPLICATION_ID, mContext.getPackageName()); i.putExtra(Browser.EXTRA_APPLICATION_ID, mContext.getPackageName());
mContext.startActivity(i); mContext.startActivity(i);
} catch (URISyntaxException ex) { } catch (Exception ex) {
// Do nothing intentionally. // Do nothing intentionally.
Log.w(TAG, "Bad URI " + mLinkUrl, ex);
} }
} }
} }
......
...@@ -10,10 +10,10 @@ import android.content.ComponentName; ...@@ -10,10 +10,10 @@ import android.content.ComponentName;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.provider.Browser; import android.provider.Browser;
import android.util.Log;
import android.webkit.WebView; import android.webkit.WebView;
import org.chromium.base.CommandLine; import org.chromium.base.CommandLine;
import org.chromium.base.Log;
import org.chromium.base.VisibleForTesting; import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.browser.ChromeSwitches; import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.UrlConstants; import org.chromium.chrome.browser.UrlConstants;
...@@ -22,7 +22,6 @@ import org.chromium.chrome.browser.util.IntentUtils; ...@@ -22,7 +22,6 @@ import org.chromium.chrome.browser.util.IntentUtils;
import org.chromium.ui.base.PageTransition; import org.chromium.ui.base.PageTransition;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException;
import java.util.List; import java.util.List;
/** /**
...@@ -79,8 +78,8 @@ public class ExternalNavigationHandler { ...@@ -79,8 +78,8 @@ public class ExternalNavigationHandler {
// Perform generic parsing of the URI to turn it into an Intent. // Perform generic parsing of the URI to turn it into an Intent.
try { try {
intent = Intent.parseUri(params.getUrl(), Intent.URI_INTENT_SCHEME); intent = Intent.parseUri(params.getUrl(), Intent.URI_INTENT_SCHEME);
} catch (URISyntaxException ex) { } catch (Exception ex) {
Log.w(TAG, "Bad URI " + params.getUrl() + ": " + ex.getMessage()); Log.w(TAG, "Bad URI " + params.getUrl(), ex);
return OverrideUrlLoadingResult.NO_OVERRIDE; return OverrideUrlLoadingResult.NO_OVERRIDE;
} }
...@@ -283,7 +282,7 @@ public class ExternalNavigationHandler { ...@@ -283,7 +282,7 @@ public class ExternalNavigationHandler {
try { try {
currentUri = new URI(params.getUrl()); currentUri = new URI(params.getUrl());
previousUri = new URI(params.getReferrerUrl()); previousUri = new URI(params.getReferrerUrl());
} catch (URISyntaxException e) { } catch (Exception e) {
currentUri = null; currentUri = null;
previousUri = null; previousUri = null;
} }
...@@ -295,7 +294,7 @@ public class ExternalNavigationHandler { ...@@ -295,7 +294,7 @@ public class ExternalNavigationHandler {
try { try {
previousIntent = Intent.parseUri( previousIntent = Intent.parseUri(
params.getReferrerUrl(), Intent.URI_INTENT_SCHEME); params.getReferrerUrl(), Intent.URI_INTENT_SCHEME);
} catch (URISyntaxException e) { } catch (Exception e) {
previousIntent = null; previousIntent = null;
} }
...@@ -386,8 +385,9 @@ public class ExternalNavigationHandler { ...@@ -386,8 +385,9 @@ public class ExternalNavigationHandler {
try { try {
Intent intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME); Intent intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME);
return intent.getPackage() != null || mDelegate.canResolveActivity(intent); return intent.getPackage() != null || mDelegate.canResolveActivity(intent);
} catch (URISyntaxException ex) { } catch (Exception ex) {
// Ignore the error. // Ignore the error.
Log.w(TAG, "Bad URI " + url, ex);
} }
return false; return false;
} }
......
...@@ -7,15 +7,13 @@ package org.chromium.content.browser; ...@@ -7,15 +7,13 @@ package org.chromium.content.browser;
import android.content.ActivityNotFoundException; import android.content.ActivityNotFoundException;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.util.Log;
import android.view.ActionMode; import android.view.ActionMode;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.View; import android.view.View;
import org.chromium.base.Log;
import org.chromium.content.browser.SelectActionModeCallback.ActionHandler; import org.chromium.content.browser.SelectActionModeCallback.ActionHandler;
import java.net.URISyntaxException;
/** /**
* Main callback class used by ContentView. * Main callback class used by ContentView.
* *
...@@ -145,8 +143,8 @@ public class ContentViewClient { ...@@ -145,8 +143,8 @@ public class ContentViewClient {
// Perform generic parsing of the URI to turn it into an Intent. // Perform generic parsing of the URI to turn it into an Intent.
try { try {
intent = Intent.parseUri(intentUrl, Intent.URI_INTENT_SCHEME); intent = Intent.parseUri(intentUrl, Intent.URI_INTENT_SCHEME);
} catch (URISyntaxException ex) { } catch (Exception ex) {
Log.w(TAG, "Bad URI " + intentUrl + ": " + ex.getMessage()); Log.w(TAG, "Bad URI " + intentUrl, ex);
return; return;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment