From 36e2f39dbc1687bedb81469a555caf06ce47a5ab Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 24 Sep 2019 16:51:51 +0200 Subject: [PATCH] Sanitize style value --- app/src/main/java/eu/faircode/email/HtmlHelper.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/HtmlHelper.java b/app/src/main/java/eu/faircode/email/HtmlHelper.java index 97109502e6..4ac0bb9d18 100644 --- a/app/src/main/java/eu/faircode/email/HtmlHelper.java +++ b/app/src/main/java/eu/faircode/email/HtmlHelper.java @@ -161,7 +161,11 @@ public class HtmlHelper { if (kv.length == 2) switch (kv[0].trim().toLowerCase(Locale.ROOT)) { case "color": - String c = kv[1].trim().toLowerCase(Locale.ROOT); + String c = kv[1] + .toLowerCase(Locale.ROOT) + .replace(" ", "") + .replace("inherit", "") + .replace("!important", ""); Integer color = null; try { @@ -174,9 +178,9 @@ public class HtmlHelper { String[] rgb = c.substring(s + 1, e).split(","); if (rgb.length == 3) color = Color.rgb( - Integer.parseInt(rgb[0].trim()), - Integer.parseInt(rgb[1].trim()), - Integer.parseInt(rgb[2].trim()) + Integer.parseInt(rgb[0]), + Integer.parseInt(rgb[1]), + Integer.parseInt(rgb[2]) ); } } else