diff --git a/app/src/main/java/eu/faircode/email/ImageHelper.java b/app/src/main/java/eu/faircode/email/ImageHelper.java
index cbcab5881d..238cbc4d4a 100644
--- a/app/src/main/java/eu/faircode/email/ImageHelper.java
+++ b/app/src/main/java/eu/faircode/email/ImageHelper.java
@@ -655,7 +655,7 @@ class ImageHelper {
}
static ByteArrayInputStream getDataUriStream(String source) {
- // "
";
@@ -667,19 +667,21 @@ class ImageHelper {
try {
// data:[][;base64],
int comma = source.indexOf(',');
- int colon = source.indexOf(':');
- int semi = source.indexOf(';');
-
if (comma < 0)
throw new IllegalArgumentException("Comma missing");
+ String header = source.substring(0, comma);
+ int colon = header.indexOf(':');
+ int fsemi = header.indexOf(';');
+ int lsemi = header.lastIndexOf(';');
+
String type = null;
- if (colon > 0 && semi > colon)
- type = source.substring(colon + 1, semi).trim();
- else if (colon > 0 && comma > colon)
+ if (colon > 0 && fsemi > colon)
+ type = source.substring(colon + 1, fsemi).trim();
+ else if (colon > 0)
type = source.substring(colon + 1, comma).trim();
- String enc = (semi > 0 && comma > semi ? source.substring(semi + 1, comma).trim() : null);
+ String enc = (lsemi > 0 ? source.substring(lsemi + 1, comma).trim() : null);
if ("image/svg".equalsIgnoreCase(type) &&
(TextUtils.isEmpty(enc) /* ASCII */ || "utf8".equalsIgnoreCase(enc))) {