From 268be8761b480e8379fb899cac84c50cad12564d Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 4 May 2020 20:19:05 +0200 Subject: [PATCH] Truncate long alt texts --- app/src/main/java/eu/faircode/email/HtmlHelper.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/java/eu/faircode/email/HtmlHelper.java b/app/src/main/java/eu/faircode/email/HtmlHelper.java index aba9384fc4..0ef4d8e710 100644 --- a/app/src/main/java/eu/faircode/email/HtmlHelper.java +++ b/app/src/main/java/eu/faircode/email/HtmlHelper.java @@ -125,6 +125,7 @@ public class HtmlHelper { private static final float FONT_LARGE = 1.25f; private static final float MIN_LUMINANCE = 0.5f; private static final int TAB_SIZE = 2; + private static final int MAX_ALT = 250; private static final int MAX_AUTO_LINK = 250; private static final int MAX_FORMAT_TEXT_SIZE = 50 * 1024; // characters private static final int MAX_FULL_TEXT_SIZE = 1024 * 1024; // characters @@ -820,6 +821,9 @@ public class HtmlHelper { String src = img.attr("src"); String tracking = img.attr("tracking"); + if (alt.length() > MAX_ALT) + alt = alt.substring(0, MAX_ALT) + "…"; + if (!show_images && !TextUtils.isEmpty(alt)) if (TextUtils.isEmpty(tracking)) img.appendText("[" + alt + "]");