From 9d7e5e5edcaaa1f134afd7ed20ee0d7a52a177e7 Mon Sep 17 00:00:00 2001 From: dkorchinskiy Date: Wed, 13 May 2015 14:56:07 +0300 Subject: [PATCH] Fix crash in web view if illegal character in url (Android only) --- .../java/src/org/cocos2dx/lib/Cocos2dxWebView.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxWebView.java b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxWebView.java index f4b1ad83aa..e4518a502c 100755 --- a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxWebView.java +++ b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxWebView.java @@ -58,11 +58,16 @@ public class Cocos2dxWebView extends WebView { class Cocos2dxWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String urlString) { - URI uri = URI.create(urlString); - if (uri != null && uri.getScheme().equals(mJSScheme)) { - Cocos2dxWebViewHelper._onJsCallback(mViewTag, urlString); - return true; + try { + URI uri = URI.create(urlString); + if (uri != null && uri.getScheme().equals(mJSScheme)) { + Cocos2dxWebViewHelper._onJsCallback(mViewTag, urlString); + return true; + } + } catch (Exception e) { + Log.d(TAG, "Failed to create URI from url"); } + return Cocos2dxWebViewHelper._shouldStartLoading(mViewTag, urlString); }