mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-22 06:01:12 +00:00
Data URI error handling
This commit is contained in:
parent
7ff497b716
commit
6a769640b6
1 changed files with 12 additions and 8 deletions
|
@ -327,7 +327,7 @@ class ImageHelper {
|
|||
fitDrawable(d, a, scale, view);
|
||||
return d;
|
||||
} catch (IllegalArgumentException ex) {
|
||||
Log.w(ex);
|
||||
Log.i(ex);
|
||||
Drawable d = context.getDrawable(R.drawable.twotone_broken_image_24);
|
||||
d.setBounds(0, 0, px, px);
|
||||
return d;
|
||||
|
@ -548,14 +548,18 @@ class ImageHelper {
|
|||
// "5ErkJggg==\" alt=\"Red dot\" />";
|
||||
|
||||
// https://en.wikipedia.org/wiki/Data_URI_scheme
|
||||
try {
|
||||
int comma = source.indexOf(',');
|
||||
if (comma < 0)
|
||||
return null;
|
||||
throw new IllegalArgumentException("Comma missing");
|
||||
|
||||
String base64 = source.substring(comma + 1);
|
||||
byte[] bytes = Base64.decode(base64.getBytes(), 0);
|
||||
|
||||
return new ByteArrayInputStream(bytes);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
String excerpt = source.substring(0, Math.min(100, source.length()));
|
||||
throw new IllegalArgumentException(excerpt, ex);
|
||||
}
|
||||
}
|
||||
|
||||
private static Drawable getCachedImage(Context context, long id, String source) {
|
||||
|
|
Loading…
Reference in a new issue