From 2eb90bc2c3756ebfc322b5479f8e29a1f070f246 Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 20 Apr 2021 08:01:03 +0200 Subject: [PATCH] Escape face names --- .../main/java/eu/faircode/email/HtmlHelper.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/HtmlHelper.java b/app/src/main/java/eu/faircode/email/HtmlHelper.java index 1f3b3bbc7e..4c19a0870c 100644 --- a/app/src/main/java/eu/faircode/email/HtmlHelper.java +++ b/app/src/main/java/eu/faircode/email/HtmlHelper.java @@ -496,8 +496,20 @@ public class HtmlHelper { } } - if (!TextUtils.isEmpty(face)) - sb.append("font-family:").append(face).append(";"); + if (!TextUtils.isEmpty(face)) { + sb.append("font-family:"); + String[] faces = face.split(","); + for (int i = 0; i < faces.length; i++) { + if (i > 0) + sb.append(','); + String f = faces[i].trim(); + if (f.contains(" ") && !f.startsWith("\"") && !f.endsWith("\"")) + sb.append('"').append(f).append('"'); + else + sb.append(f); + } + sb.append(";"); + } font.attr("style", sb.toString());