From 37a08f3d7b03fe5a125945a86247aebf45e5654e Mon Sep 17 00:00:00 2001 From: Sebastian Kaspari Date: Thu, 14 Sep 2017 12:34:10 +0200 Subject: [PATCH] Prevent onURLChanged() being called with null URL. (#1310) --- .../org/mozilla/focus/webkit/FocusWebViewClient.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/webkit/java/org/mozilla/focus/webkit/FocusWebViewClient.java b/app/src/webkit/java/org/mozilla/focus/webkit/FocusWebViewClient.java index 1dfc538db63..41b561ecb14 100644 --- a/app/src/webkit/java/org/mozilla/focus/webkit/FocusWebViewClient.java +++ b/app/src/webkit/java/org/mozilla/focus/webkit/FocusWebViewClient.java @@ -132,12 +132,14 @@ public WebResourceResponse shouldInterceptRequest(WebView view, final WebResourc // not have a trailing URL (usually no trailing / when a link is entered via UrlInputFragment), // hence we do a somewhat convoluted test: final String requestURL = request.getUrl().toString(); - if (UrlUtils.urlsMatchExceptForTrailingSlash(currentPageURL, requestURL)) { + final String currentURL = currentPageURL; + + if (UrlUtils.urlsMatchExceptForTrailingSlash(currentURL, requestURL)) { view.post(new Runnable() { @Override public void run() { if (callback != null) { - callback.onURLChanged(currentPageURL); + callback.onURLChanged(currentURL); } } }); @@ -208,8 +210,8 @@ public void onPageFinished(WebView view, final String url) { // The URL which is supplied in onPageFinished() could be fake (see #301), but webview's // URL is always correct _except_ for error pages final String viewURL = view.getUrl(); - if (!UrlUtils.isInternalErrorURL(viewURL)) { - callback.onURLChanged(view.getUrl()); + if (!UrlUtils.isInternalErrorURL(viewURL) && viewURL != null) { + callback.onURLChanged(viewURL); } } super.onPageFinished(view, url);