From 13882be6d009b59847c29972e7d47d523bbb524f Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 26 Jul 2019 21:33:32 +0200 Subject: [PATCH] Parse img width/height separately --- .../java/eu/faircode/email/HtmlHelper.java | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/HtmlHelper.java b/app/src/main/java/eu/faircode/email/HtmlHelper.java index 7436dca148..67041f692b 100644 --- a/app/src/main/java/eu/faircode/email/HtmlHelper.java +++ b/app/src/main/java/eu/faircode/email/HtmlHelper.java @@ -235,26 +235,30 @@ public class HtmlHelper { // Annotate source with width and height if (img.hasAttr("src")) { - try { - int width = 0; - int height = 0; + int width = 0; + int height = 0; + try { String awidth = img.attr("width"); - String aheight = img.attr("height"); - if (!TextUtils.isEmpty(awidth) && !"auto".equals(awidth.toLowerCase())) width = Integer.parseInt(awidth); + } catch (NumberFormatException ex) { + Log.w(ex); + } + + try { + String aheight = img.attr("height"); if (!TextUtils.isEmpty(aheight) && !"auto".equals(aheight.toLowerCase())) height = Integer.parseInt(aheight); - - if (width != 0 || height != 0) { - String src = img.attr("src"); - AnnotatedSource a = new AnnotatedSource(src, width, height); - img.attr("src", a.getAnnotated()); - } } catch (NumberFormatException ex) { Log.w(ex); } + + if (width != 0 || height != 0) { + String src = img.attr("src"); + AnnotatedSource a = new AnnotatedSource(src, width, height); + img.attr("src", a.getAnnotated()); + } } }