mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-25 18:35:06 +01:00
Support data URI images with filenames
This commit is contained in:
@@ -655,7 +655,7 @@ class ImageHelper {
|
||||
}
|
||||
|
||||
static ByteArrayInputStream getDataUriStream(String source) {
|
||||
// "<img src=\"data:image/png;base64,iVBORw0KGgoAAA" +
|
||||
// "<img src=\"data:image/png;filename=dot.png;base64,iVBORw0KGgoAAA" +
|
||||
// "ANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4" +
|
||||
// "//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU" +
|
||||
// "5ErkJggg==\" alt=\"Red dot\" />";
|
||||
@@ -667,19 +667,21 @@ class ImageHelper {
|
||||
try {
|
||||
// data:[<mediatype>][;base64],<data>
|
||||
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))) {
|
||||
|
||||
Reference in New Issue
Block a user