From 859c2b4496618c8142c70610ebba395e9aa4d5dc Mon Sep 17 00:00:00 2001 From: cyBerta Date: Fri, 3 Nov 2017 15:17:45 +0100 Subject: #8778 fixes invalid provider error handling --- app/src/main/java/se/leap/bitmaskclient/ConfigHelper.java | 2 +- app/src/main/java/se/leap/bitmaskclient/ProviderApiBase.java | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'app/src/main') diff --git a/app/src/main/java/se/leap/bitmaskclient/ConfigHelper.java b/app/src/main/java/se/leap/bitmaskclient/ConfigHelper.java index 4929f040..33b2e225 100644 --- a/app/src/main/java/se/leap/bitmaskclient/ConfigHelper.java +++ b/app/src/main/java/se/leap/bitmaskclient/ConfigHelper.java @@ -47,7 +47,7 @@ public class ConfigHelper { } else { return false; } - } catch (JSONException e) { + } catch (NullPointerException | JSONException e) { return false; } } diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderApiBase.java b/app/src/main/java/se/leap/bitmaskclient/ProviderApiBase.java index caa48231..bf1c3941 100644 --- a/app/src/main/java/se/leap/bitmaskclient/ProviderApiBase.java +++ b/app/src/main/java/se/leap/bitmaskclient/ProviderApiBase.java @@ -687,6 +687,17 @@ public abstract class ProviderApiBase extends IntentService { return CA_CERT_DOWNLOADED; } + protected boolean isValidJson(String jsonString) { + try { + new JSONObject(jsonString); + return true; + } catch(JSONException e) { + return false; + } catch(NullPointerException e) { + return false; + } + } + protected boolean validCertificate(String cert_string) { boolean result = false; if (!ConfigHelper.checkErroneousDownload(cert_string)) { -- cgit v1.2.3