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

Commit 5eb79ce

Browse files
bluemarvinkeianhzo
authored andcommitted
Handle exceptions thrown by java.net.URI (#1918)
1 parent b22108a commit 5eb79ce

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

app/src/common/shared/org/mozilla/vrbrowser/browser/engine/SessionStack.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -793,11 +793,14 @@ public int getUaMode() {
793793
private static final String MOBILE_PREFIX = "mobile.";
794794

795795
private String checkForMobileSite(String aUri) {
796+
if (aUri == null) {
797+
return null;
798+
}
796799
String result = null;
797800
URI uri;
798801
try {
799802
uri = new URI(aUri);
800-
} catch (URISyntaxException e) {
803+
} catch (URISyntaxException | NullPointerException e) {
801804
Log.d(LOGTAG, "Error parsing URL: " + aUri + " " + e.getMessage());
802805
return null;
803806
}
@@ -816,7 +819,7 @@ private String checkForMobileSite(String aUri) {
816819
try {
817820
uri = new URI(uri.getScheme(), authority.substring(foundPrefix.length()), uri.getPath(), uri.getQuery(), uri.getFragment());
818821
result = uri.toString();
819-
} catch (URISyntaxException e) {
822+
} catch (URISyntaxException | NullPointerException e) {
820823
Log.d(LOGTAG, "Error dropping mobile prefix from: " + aUri + " " + e.getMessage());
821824
}
822825
}

app/src/common/shared/org/mozilla/vrbrowser/ui/views/NavigationURLBar.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,9 @@ public void setURL(String aURL) {
313313
try {
314314
aURL = URLDecoder.decode(aURL, "UTF-8");
315315

316-
} catch (UnsupportedEncodingException e) {
316+
} catch (UnsupportedEncodingException | IllegalArgumentException e) {
317317
e.printStackTrace();
318+
aURL = "";
318319
}
319320
if (aURL.startsWith("jar:")) {
320321
return;

0 commit comments

Comments
 (0)