From 95ba52b761c4fcdab5d73c864a042c29ff8f82fc Mon Sep 17 00:00:00 2001 From: LucasGGamerM Date: Wed, 8 May 2024 20:09:00 -0300 Subject: [PATCH] fix(import-backup): check if json is not null before importing --- .../fragments/settings/SettingsAboutAppFragment.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsAboutAppFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsAboutAppFragment.java index 17585ff8b0..f8d086ee02 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsAboutAppFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsAboutAppFragment.java @@ -233,6 +233,12 @@ public void onActivityResult(int requestCode, int resultCode, Intent data){ String jsonString=stringBuilder.toString(); Gson gson=new GsonBuilder().setObjectToNumberStrategy(ToNumberPolicy.LONG_OR_DOUBLE).create(); + + //check if json is not null + if(jsonString.isEmpty()) { + throw new IOException(); + } + JsonObject jsonObject=JsonParser.parseString(jsonString).getAsJsonObject(); //check if json has required attributes