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

Commit a6ae172

Browse files
authored
Fix crash if onLoadError uri parameter is null (#3000)
1 parent 1915c2d commit a6ae172

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,7 @@ public GeckoResult<GeckoSession> onNewSession(@NonNull GeckoSession aSession, @N
969969
}
970970

971971
@Override
972-
public GeckoResult<String> onLoadError(@NonNull GeckoSession session, String uri, @NonNull WebRequestError error) {
972+
public GeckoResult<String> onLoadError(@NonNull GeckoSession session, @Nullable String uri, @NonNull WebRequestError error) {
973973
Log.d(LOGTAG, "Session onLoadError: " + uri);
974974

975975
return GeckoResult.fromValue(InternalPages.createErrorPageDataURI(mContext, uri, error.code));

app/src/common/shared/org/mozilla/vrbrowser/utils/InternalPages.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import android.content.Context;
44
import android.util.Base64;
55

6+
import androidx.annotation.Nullable;
7+
68
import org.mozilla.vrbrowser.R;
79

810
import org.mozilla.geckoview.WebRequestError;
@@ -115,7 +117,7 @@ public static PageResources create(int html, int css) {
115117
}
116118

117119
public static String createErrorPageDataURI(Context context,
118-
String uri,
120+
@Nullable String uri,
119121
int errorType) {
120122
String html = ErrorPages.INSTANCE.createErrorPage(
121123
context,
@@ -134,9 +136,10 @@ public static String createErrorPageDataURI(Context context,
134136
showSSLAdvanced = false;
135137
}
136138

137-
html = html
138-
.replace("%url%", uri)
139-
.replace("%advancedSSLStyle%", showSSLAdvanced ? "block" : "none");
139+
if (uri != null) {
140+
html = html.replace("%url%", uri);
141+
}
142+
html = html.replace("%advancedSSLStyle%", showSSLAdvanced ? "block" : "none");
140143

141144
return "data:text/html;base64," + Base64.encodeToString(html.getBytes(), Base64.NO_WRAP);
142145
}

0 commit comments

Comments
 (0)