From 7890a36d450ab0ef356309f9bb3eb4e5d5eb145d Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 4 Feb 2020 10:19:17 +0100 Subject: [PATCH] Added color workarounds --- .../main/java/eu/faircode/email/HtmlHelper.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/HtmlHelper.java b/app/src/main/java/eu/faircode/email/HtmlHelper.java index 8bf80f79d4..d8652c41e6 100644 --- a/app/src/main/java/eu/faircode/email/HtmlHelper.java +++ b/app/src/main/java/eu/faircode/email/HtmlHelper.java @@ -662,24 +662,28 @@ public class HtmlHelper { private static Integer parseColor(@NonNull String value, boolean dark) { // https://developer.mozilla.org/en-US/docs/Web/CSS/color_value String c = value + .replace("null", "") .replace("none", "") .replace("unset", "") .replace("inherit", "") .replace("initial", "") .replace("windowtext", "") .replace("transparent", "") - .replaceAll("[^a-z0-9(),.%#]", ""); + .replaceAll("[^a-z0-9(),.%#]", "") + .replaceAll("#+", "#"); Integer color = null; try { if (TextUtils.isEmpty(c)) return null; else if (c.startsWith("#")) { - String code = c.substring(1); - if (x11ColorMap.containsKey(code)) // workaround - color = x11ColorMap.get(code) | 0xFF000000; - else - color = Integer.decode(c) | 0xFF000000; + if (c.length() > 1) { + String code = c.substring(1); + if (x11ColorMap.containsKey(code)) // workaround + color = x11ColorMap.get(code) | 0xFF000000; + else + color = Integer.decode(c) | 0xFF000000; + } } else if (c.startsWith("rgb") || c.startsWith("hsl")) { int s = c.indexOf("("); int e = c.indexOf(")");