Skip to content

Commit

Permalink
Revert of Catch Exception for Intent.parseUri instead of URISyntaxExc…
Browse files Browse the repository at this point in the history
…eption (patchset chromium#2 id:20001 of https://codereview.chromium.org/1132473004/)

Reason for revert:
broke findbugs: http://build.chromium.org/p/chromium.linux/builders/Android%20Clang%20Builder%20%28dbg%29/builds/59364

slipped through CQ because analyze in android_clang_dbg_recipe decided it didn't need to compile: http://build.chromium.org/p/tryserver.chromium.linux/builders/android_clang_dbg_recipe/builds/75301

Original issue's description:
> 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
>
> Committed: https://crrev.com/e9785bb71f9e0b8a9a3ba321c2c6483c8805e5a1
> Cr-Commit-Position: refs/heads/master@{#329163}

TBR=torne@chromium.org,tedchoc@chromium.org,jaekyun@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=484336

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

Cr-Commit-Position: refs/heads/master@{#329170}
  • Loading branch information
jbudorick authored and Commit bot committed May 11, 2015
1 parent 74bb4de commit c74b42e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,21 @@
import android.content.Context;
import android.content.Intent;
import android.provider.Browser;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.webkit.URLUtil;
import android.webkit.WebChromeClient;
import android.widget.FrameLayout;

import org.chromium.base.Log;
import org.chromium.content.browser.ContentVideoViewClient;
import org.chromium.content.browser.ContentViewClient;
import org.chromium.content.browser.ContentViewCore;
import org.chromium.content.browser.SelectActionMode;
import org.chromium.content.browser.SelectActionModeCallback.ActionHandler;

import java.net.URISyntaxException;

/**
* ContentViewClient implementation for WebView
*/
Expand Down Expand Up @@ -60,8 +62,8 @@ public void onStartContentIntent(Context context, String contentUrl) {
// Perform generic parsing of the URI to turn it into an Intent.
try {
intent = Intent.parseUri(contentUrl, Intent.URI_INTENT_SCHEME);
} catch (Exception ex) {
Log.w(TAG, "Bad URI " + contentUrl, ex);
} catch (URISyntaxException ex) {
Log.w(TAG, "Bad URI " + contentUrl + ": " + ex.getMessage());
return;
}
// Sanitize the Intent, ensuring web pages can not bypass browser
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import org.chromium.content_public.browser.WebContents;
import org.chromium.content_public.browser.WebContentsObserver;

import java.net.URISyntaxException;

/**
* Java side of Android implementation of the website settings UI.
*/
Expand Down Expand Up @@ -210,7 +212,7 @@ public void onClick(View v) {
i.putExtra(Browser.EXTRA_CREATE_NEW_TAB, true);
i.putExtra(Browser.EXTRA_APPLICATION_ID, mContext.getPackageName());
mContext.startActivity(i);
} catch (Exception ex) {
} catch (URISyntaxException ex) {
// Do nothing intentionally.
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
import android.content.Intent;
import android.net.Uri;
import android.provider.Browser;
import android.util.Log;
import android.webkit.WebView;

import org.chromium.base.CommandLine;
import org.chromium.base.Log;
import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.UrlConstants;
Expand All @@ -22,6 +22,7 @@
import org.chromium.ui.base.PageTransition;

import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;

/**
Expand Down Expand Up @@ -78,8 +79,8 @@ public OverrideUrlLoadingResult shouldOverrideUrlLoading(ExternalNavigationParam
// Perform generic parsing of the URI to turn it into an Intent.
try {
intent = Intent.parseUri(params.getUrl(), Intent.URI_INTENT_SCHEME);
} catch (Exception ex) {
Log.w(TAG, "Bad URI " + params.getUrl(), ex);
} catch (URISyntaxException ex) {
Log.w(TAG, "Bad URI " + params.getUrl() + ": " + ex.getMessage());
return OverrideUrlLoadingResult.NO_OVERRIDE;
}

Expand Down Expand Up @@ -282,7 +283,7 @@ private OverrideUrlLoadingResult shouldOverrideUrlLoadingInternal(
try {
currentUri = new URI(params.getUrl());
previousUri = new URI(params.getReferrerUrl());
} catch (Exception e) {
} catch (URISyntaxException e) {
currentUri = null;
previousUri = null;
}
Expand All @@ -294,7 +295,7 @@ private OverrideUrlLoadingResult shouldOverrideUrlLoadingInternal(
try {
previousIntent = Intent.parseUri(
params.getReferrerUrl(), Intent.URI_INTENT_SCHEME);
} catch (Exception e) {
} catch (URISyntaxException e) {
previousIntent = null;
}

Expand Down Expand Up @@ -385,7 +386,7 @@ public boolean canExternalAppHandleUrl(String url) {
try {
Intent intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME);
return intent.getPackage() != null || mDelegate.canResolveActivity(intent);
} catch (Exception ex) {
} catch (URISyntaxException ex) {
// Ignore the error.
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.ActionMode;
import android.view.KeyEvent;
import android.view.View;

import org.chromium.base.Log;
import org.chromium.content.browser.SelectActionModeCallback.ActionHandler;

import java.net.URISyntaxException;

/**
* Main callback class used by ContentView.
*
Expand Down Expand Up @@ -143,8 +145,8 @@ public void onStartContentIntent(Context context, String intentUrl) {
// Perform generic parsing of the URI to turn it into an Intent.
try {
intent = Intent.parseUri(intentUrl, Intent.URI_INTENT_SCHEME);
} catch (Exception ex) {
Log.w(TAG, "Bad URI " + intentUrl, ex);
} catch (URISyntaxException ex) {
Log.w(TAG, "Bad URI " + intentUrl + ": " + ex.getMessage());
return;
}

Expand Down

0 comments on commit c74b42e

Please sign in to comment.