Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Handle exceptions thrown by java.net.URI (#1918)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluemarvin authored and keianhzo committed Oct 7, 2019
1 parent b22108a commit 5eb79ce
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -793,11 +793,14 @@ public int getUaMode() {
private static final String MOBILE_PREFIX = "mobile.";

private String checkForMobileSite(String aUri) {
if (aUri == null) {
return null;
}
String result = null;
URI uri;
try {
uri = new URI(aUri);
} catch (URISyntaxException e) {
} catch (URISyntaxException | NullPointerException e) {
Log.d(LOGTAG, "Error parsing URL: " + aUri + " " + e.getMessage());
return null;
}
Expand All @@ -816,7 +819,7 @@ private String checkForMobileSite(String aUri) {
try {
uri = new URI(uri.getScheme(), authority.substring(foundPrefix.length()), uri.getPath(), uri.getQuery(), uri.getFragment());
result = uri.toString();
} catch (URISyntaxException e) {
} catch (URISyntaxException | NullPointerException e) {
Log.d(LOGTAG, "Error dropping mobile prefix from: " + aUri + " " + e.getMessage());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,9 @@ public void setURL(String aURL) {
try {
aURL = URLDecoder.decode(aURL, "UTF-8");

} catch (UnsupportedEncodingException e) {
} catch (UnsupportedEncodingException | IllegalArgumentException e) {
e.printStackTrace();
aURL = "";
}
if (aURL.startsWith("jar:")) {
return;
Expand Down

0 comments on commit 5eb79ce

Please sign in to comment.