From d87120d8480eb1cd7d59577a6c8eb49135373758 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 23 May 2020 22:19:16 +0200 Subject: [PATCH] Check if comma in data URI --- app/src/main/java/eu/faircode/email/ImageHelper.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/ImageHelper.java b/app/src/main/java/eu/faircode/email/ImageHelper.java index 3f852fc4fe..39da2d01d1 100644 --- a/app/src/main/java/eu/faircode/email/ImageHelper.java +++ b/app/src/main/java/eu/faircode/email/ImageHelper.java @@ -519,7 +519,11 @@ class ImageHelper { // "//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU" + // "5ErkJggg==\" alt=\"Red dot\" />"; - String base64 = source.substring(source.indexOf(',') + 1); + int comma = source.indexOf(','); + if (comma < 0) + return null; + + String base64 = source.substring(comma + 1); byte[] bytes = Base64.decode(base64.getBytes(), 0); return BitmapFactory.decodeByteArray(bytes, 0, bytes.length);